diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 362b969..ad33636 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -5,6 +5,7 @@ import ( "dwelling-radio/pkg/watcher" "encoding/json" "io" + "log" "net/http" "os" "sync" @@ -129,6 +130,8 @@ func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) { return nil, err } + log.Println(playlistPath, buf) + lines := bytes.Split(buf, []byte("\n")) if len(lines) < 2 { @@ -185,6 +188,9 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) { if lastPlayedCache == nil { lastPlayedCache = make([]Song, 0, n) + if songs, err := icecastLastPlayedSongs(playlistPath, n); err == nil && len(songs) > 0 { + lastPlayedCache = append(lastPlayedCache, songs...) + } } go func() {