Load and store most listened song.
This commit is contained in:
parent
1ab82003e6
commit
3207395b67
@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -38,6 +39,12 @@ func main() {
|
||||
defer os.Remove(addr)
|
||||
}
|
||||
|
||||
if data, err := os.ReadFile(config.MostListenedSongPath); err == nil {
|
||||
if err := radio.LoadMostListenedSong(data); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
playlistWatcher := radio.NewPlaylistLogWatcher()
|
||||
if err := playlistWatcher.Watch(config.Icecast.Playlist, config.ListLastNSongs); err != nil {
|
||||
log.Fatalln(err)
|
||||
@ -82,4 +89,6 @@ func main() {
|
||||
if err := srv.Stop(); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
os.WriteFile(config.MostListenedSongPath, radio.StoreMostListenedSong(), fs.ModePerm)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user