librespot icon indicating copy to clipboard operation
librespot copied to clipboard

Only subsection of large playlist gets played in spotify connect

Open nyavorski opened this issue 5 years ago • 13 comments
trafficstars

Hi -

I am experiencing an issue where all the songs in a playlist cannot be played through the connect feature. It looks to me like only 80 songs get sent to the play queue, and the queue does not get sent any 'new' songs. When the end of the queue is reached, the initial 80 songs that were sent to the queue are then played again.

[2020-03-03T01:42:06Z INFO librespot] librespot (). Built on 2020-03-02. Build ID: a527MUNO

Expected behavior (casting to Spotify app on Android TV) https://imgur.com/mX7CePc

Observed behavior (casting to librespot client on a raspberry pi) https://imgur.com/a/zMnasMu

Thanks and let me know what additional info would be helpful.

nyavorski avatar Mar 03 '20 01:03 nyavorski

I can confirm this behaviour: If you shuffle a playlist, the same 20 - 30 songs are played in the same order over and over again.

mrwsl avatar Mar 03 '20 07:03 mrwsl

It's probably sending the rest of the tracks as context, which we don't handle for playlists. Can you check the debugging logs to confirm? Else I'll take a look when I get some time later this week..

ashthespy avatar Mar 05 '20 11:03 ashthespy

Here is a log snippet of me loading a playlist, skipping to the last song, skipping the track, and it reloading the same bucket of songs. [2020-03-05T20:02:11Z DEBUG librespot_connect::spirc] Loading context: <spotify:user:REDACTED:collection> index: [80] of 81

https://pastebin.com/raw/MjiKdw3s

edit: when playing from a playlist instead of 'Liked Songs' [2020-03-05T21:23:13Z DEBUG librespot_connect::spirc] Loading context: spotify:user:xxx:playlist:foo index: [0] of 81

nyavorski avatar Mar 05 '20 20:03 nyavorski

Looks like we need to fetch context for spotify:user:xxx:collection as well now..

ashthespy avatar Mar 05 '20 20:03 ashthespy

I'm not sure this issue has been fixed - I am still only seeing 90 or so songs being played and then librespot behaves as if the end of the playlist has been reached.

I am completely guessing, but since the web interfaces loads the playlist in chunks (when you scroll to the bottom you have to wait for more songs to load) I am wondering whether the API only returns 80 or so songs at a time, and librespot never refreshes this list?

As a data point, when running librespot compiled from around November 2019, I could extend this limit by clicking play in the web interface. Each time I clicked play, it would start the 80 songs from that point. However while I am now testing @ashthespy's gapless patch against the master branch I have noticed that this no longer happens, and clicking play within the playlist does not refresh the 80 songs.

This results in odd behaviour, such as clicking 'play' in the web interface, then librespot may only play a couple of songs and then stop, because you happened to click play towards the end of the current block of 80-90 songs. You have to then go back and play the following song manually before it will continue with the playlist, but it will only continue for another 80-90 songs or so.

Does librespot need to refresh the playlist at certain intervals?

Malvineous avatar Jun 03 '20 04:06 Malvineous

I too am struggling with this issue, compiled from latest release

mitchgreen avatar Nov 02 '21 03:11 mitchgreen

Please post the playlist you are encountering this issue with.

roderickvd avatar Nov 02 '21 05:11 roderickvd

Please post the playlist you are encountering this issue with.

Here is a test playlist of mine that I was able to replicate the issue with. Playing with repeat all enabled and shuffle off, song number 81 plays and then the playlist repeats from the beginning as if it had reached the end of the playlist.

https://open.spotify.com/playlist/18uyEBN6Qwmw0Kulxsw7Xk?si=c21466dfde274e60

mitchgreen avatar Nov 02 '21 15:11 mitchgreen

Running librespot with --verbose and reviewing the logs, i'm seeing that the logs indicate [2021-11-03T03:20:42Z DEBUG librespot_connect::spirc] Frame has 81 tracks

Playback works as expected up-to and including track 81 after which Spotify stops (when repeat is not enabled) or loops back to the beginning of the playlist (if repeat all is enabled)

mitchgreen avatar Nov 03 '21 03:11 mitchgreen

Re-opening. I suspect it is related to #434 where we need to support pagination contexts. I'm still on the fence whether we should fix this here and now or as part of the new-api efforts.

roderickvd avatar Nov 03 '21 08:11 roderickvd

Any update on this one? Does the new-api branch have a fix, or perhaps some relevant changes that might mitigate it?

BenTilbrook avatar Jan 01 '22 03:01 BenTilbrook

Not yet. It's part of the new-api scope, which has picked up development again, but we haven't gotten around to it yet. I first want to move from spirc to dealer and see if pagination is still necessary at all.

roderickvd avatar Jan 01 '22 15:01 roderickvd

Reporting back: still the case even with the latest commits. What I tried, but didn't work, is to implement pagination by querying the Apollo station with tracks scope and autoplay=false. But no matter what you set autoplay to, it always returns autoplay recommendations. See my latest comments in #434 on how this may be fixed going forward.

roderickvd avatar Oct 01 '22 22:10 roderickvd