1
0

Load and store most listened song.

This commit is contained in:
Alexander Andreev 2023-03-13 01:41:13 +04:00
parent 1ab82003e6
commit 3207395b67
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -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)
}