Added most listened song and song list length. Also removed a year 2022 from a version string.
This commit is contained in:
parent
07d11ce3ff
commit
5a058aa706
@ -5,6 +5,7 @@ import (
|
||||
"dwelling-radio/internal/radio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -15,11 +16,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
listenAddress = flag.String("listen", "/var/run/dwelling-radio/sock", "listen address (ip:port|unix_path)")
|
||||
playlist = flag.String("playlist", "", "path to a playlist")
|
||||
icecastUrl = flag.String("ic-url", "", "URL to an Icecast's status-json.xsl")
|
||||
icecastPlaylistPath = flag.String("ic-playlist", "/var/log/icecast/playlist.log", "path to an Icecast's playlist.log file")
|
||||
songListLen = flag.Int("list-length", 10, "number of songs to show in last N songs table")
|
||||
listenAddress = flag.String("listen", "/var/run/dwelling-radio/sock", "listen address (ip:port|unix_path)")
|
||||
playlist = flag.String("playlist", "", "path to a playlist")
|
||||
songListLen = flag.Int("list-length", 10, "number of songs to show in last N songs table")
|
||||
mostListenedSongPath = flag.String("mls-file", "/mnt/data/appdata/radio/mostlistenedsong", "path to a file that stores info about the most listened song")
|
||||
|
||||
showVersion = flag.Bool("v", false, "show version")
|
||||
)
|
||||
@ -31,7 +31,7 @@ func main() {
|
||||
log.SetFlags(log.Lshortfile)
|
||||
|
||||
if *showVersion {
|
||||
fmt.Println("dwelling-radio ver.", version, "\nCopyright (c) 2022,2023 Alexander \"Arav\" Andreev <me@arav.su>")
|
||||
fmt.Println("dwelling-radio ver.", version, "\nCopyright (c) 2023 Alexander \"Arav\" Andreev <me@arav.su>")
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,7 +43,13 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
djh := ihttp.NewDJHandlers(lstnrs, plylst)
|
||||
mlsf, err := os.ReadFile(*mostListenedSongPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
radio.LoadMostListenedSong(mlsf)
|
||||
|
||||
djh := ihttp.NewDJHandlers(lstnrs, plylst, *songListLen)
|
||||
|
||||
s := r.Sub("/listener")
|
||||
s.Handler(http.MethodGet, "/", djh.ListenersGet)
|
||||
@ -63,6 +69,14 @@ func main() {
|
||||
}
|
||||
|
||||
defer func() {
|
||||
fileData := radio.StoreMostListenedSong()
|
||||
if fileData != nil {
|
||||
err := os.WriteFile(*mostListenedSongPath, fileData, fs.ModePerm)
|
||||
if err != nil {
|
||||
log.Println("failed to store a most listened song:", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := srv.Stop(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user