Refill
All checks were successful
builder / build (push) Successful in 47s

This commit is contained in:
abs3nt 2024-08-22 00:17:10 -07:00
parent e05de59160
commit 57c97cddb4
Signed by: abs3nt
GPG Key ID: A7BD96A8BAB04C09

View File

@ -365,8 +365,9 @@ func (c *Commander) RefillRadio() error {
if err != nil { if err != nil {
return err return err
} }
paused := false
if !status.Playing { if !status.Playing {
return nil paused = true
} }
toRemove := []spotify.ID{} toRemove := []spotify.ID{}
radioPlaylist, db, err := c.GetRadioPlaylist("") radioPlaylist, db, err := c.GetRadioPlaylist("")
@ -374,15 +375,15 @@ func (c *Commander) RefillRadio() error {
return err return err
} }
if status.PlaybackContext.URI != radioPlaylist.URI {
return nil
}
playlistItems, err := c.Client().GetPlaylistItems(c.Context, radioPlaylist.ID) playlistItems, err := c.Client().GetPlaylistItems(c.Context, radioPlaylist.ID)
if err != nil { if err != nil {
return fmt.Errorf("orig playlist items: %w", err) return fmt.Errorf("orig playlist items: %w", err)
} }
if status.PlaybackContext.URI != radioPlaylist.URI || paused {
return c.RadioFromPlaylist(radioPlaylist.SimplePlaylist)
}
page := 0 page := 0
for { for {
tracks, err := c.Client().GetPlaylistItems(c.Context, radioPlaylist.ID, spotify.Limit(50), spotify.Offset(page*50)) tracks, err := c.Client().GetPlaylistItems(c.Context, radioPlaylist.ID, spotify.Limit(50), spotify.Offset(page*50))