hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.
BSD 2-Clause "Simplified" License
4.93k stars 204 forks source link

Playlists tab only shows 50 items #1421

Closed ThomasFrans closed 4 months ago

ThomasFrans commented 5 months ago

Describe the bug

ncspot only shows 50 playlists in the playlists tab. I counted them as I suspect it's a problem with paging which has a hard coded value that is 50 if I remember correctly. I think it had something to do with the Spotify API limiting requests to 50 items. I'm not 100% sure about this. When I scroll to the bottom of the list, more items aren't loaded, so it's not just a missing paging indicator.

To Reproduce

  1. Make sure you have 50 playlists in your library
  2. Open ncspot
  3. Go to tabs

Expected behavior

All playlists should load or a paging indicator should be shown.

Screenshots

image

System

Setup 1

Setup 2

Setup 3

Setup 4

Backtrace/Debug log

\/

Additional context

I opened ncspot on Linux where it had already run before and saw way more playlists before it updated the library and most of them disappeared and only 50 were left. I moved some playlists into folders on Spotify recently, so I thought that might have been it. I tried moving them all out of the folders again, waited a few hours so any caching on their end would probably be gone and tried again without luck. The bug still occurs.

ThomasFrans commented 5 months ago

Slightly worrying: I think it might not be ncspot but Spotify that's causing this. The reason is that when I open ncspot, I can't go to the Spotify website anymore and instead get a "429: Too many requests" error. It probably sees me loading my library as excessive use of the API as ncspot loads everything at once. I've been seeing this error for a while now but didn't make the connection until now. ncspot starts in the background so that's probably why I got that error sometimes without even having opened Spotify itself that day.

A solution would be lazy loading of container items, but that wouldn't be easy to implement...

Bettehem commented 5 months ago

Hello, I have noticed the 429 error too when developing my music bot which in case of Spotify fetches track metadata etc from their API. When Spotify returns a 429 error code, it also returns a "Retry-After" header field, which contains a value in milliseconds for how long you should wait before the next request. So for me the solution was to just wait for the given time and then do the next request

ThomasFrans commented 5 months ago

Oh I didn't know. For me the 429 error on their website lasts for several minutes though so I don't know whether that's a solution. I also think ncspot already has handling for 429 in spotify_api.rs, so something must have changed on Spotify's end or the 429 logic in ncspot was never used before.

Bettehem commented 5 months ago

If I recall, the "Retry-After" keeps increasing if it is not respected, so that could be why your 429 error lasts for minutes

ThomasFrans commented 5 months ago

That might be the reason for the long waiting time then. Still, something must have changed as for example v0.13.0 used to work fine and now it doesn't. I don't know what changed, but I do know that I have way more than 50 playlists and only 50 of them are showing currently. I will try to look into this further when I have the time, but that will sadly not be soon 😢

ethanredmond2 commented 5 months ago

It's good that it's not just me having this problem, I was quite worried when I opened ncspot this morning!

I can confirm this happens for me too, although I'm on v0.13.0 and it's still broken, so I suspect it's a change on Spotify's end with their API.

I have around 200 playlists that used to all show in ncspot using the "Custom order" I ordered them all in Spotify by dragging and dropping. Now ncspot only shows the first 50 most recent playlists, according to the order I last listened to each one in Spotify, with the most recent at the top and least recent at the bottom.

I haven't changed anything with Spotify like putting playlists into folders, and I have all my playlists in many different nested folders anyway.

I don't know how to check if I get a 429 error from Spotify but if you show me how I'll see if I can confirm that happens for me too :)

orange-toothbrush commented 5 months ago

Having a similar issue after update, except no playlists are showing up at all. Tracks, Albums, and Artists works, but not Podcasts or Playlists. Hope this helps.

ThomasFrans commented 5 months ago

I don't know how to check if I get a 429 error from Spotify but if you show me how I'll see if I can confirm that happens for me too :)

@ethanredmond2 It shows up when I browse to the web player. I get a plain white page with 439 instead.

ethanredmond2 commented 5 months ago

Interesting, my Spotify web player works fine and has no errors (open.spotify.com), although it very briefly shows this error before loading (it's probably unrelated):

image

hrkfdn commented 5 months ago

Possibly related: https://github.com/librespot-org/librespot/issues/1261

hrkfdn commented 5 months ago

One way to verify this could be by checking if the problem is fixed with this branch: https://github.com/hrkfdn/ncspot/pull/1244

ThomasFrans commented 5 months ago

That fixes it. I guess I'll just use that branch for now.

hrkfdn commented 4 months ago

Are you still experiencing this with the release? I can't reproduce it with the main branch..

ThomasFrans commented 4 months ago

I think the combination of VPN + downloading the entire library was causing rate limits. I noticed that every time I opened ncspot, the web player would become broken as well. I kind of stopped using ncspot because of this, which is sad as I like it way more than the web player, but the rate limits just make it impossible. I also received very frequent emails that forced me to reset my password, which was probably caused by the same problem.

This issue is probably only a problem with a VPN, so nothing that can easily be solved in ncspot. I will close this.

ethanredmond2 commented 4 months ago

It's not limited to 50 playlists for me anymore, it shows all my playlists. It's possible Spotify fixed the problem on their end? Interestingly though, my playlists are now in order of most recently played instead of the custom order I manually dragged and dropped them in the Spotify interface. Using the branch also didn't fix the 50 playlists limit for me, although it's possible I did it wrong.

ThomasFrans commented 4 months ago

I don't know whether it was the branch that solved it or it just happened to work that time. I'll probably come back to ncspot at some point. I might just remove my VPN as it causes more problems than it's solving (ncspot > online "privacy")