hrkfdn / ncspot

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

Playlists do not load #1425

Open OtaK opened 3 months ago

OtaK commented 3 months ago

Describe the bug Playlists do not load.

To Reproduce Steps to reproduce the behavior:

  1. Clear playlist cache (by removing .cache/ncspot/playlists.db)
  2. Start ncspot
  3. Go to the playlists tab
  4. See error

Expected behavior Playlists list should display

Screenshots N/A

System (please complete the following information):

Backtrace/Debug log

[2024-03-26][00:43:24] [ureq::unit] [DEBUG] response 200 to GET https://api.spotify.com/v1/me/playlists?offset=0&limit=50
[2024-03-26][00:43:24] [ureq::pool] [DEBUG] adding stream to pool: https|api.spotify.com|443 -> Stream(RustlsStream)
[2024-03-26][00:43:24] [ureq::pool] [DEBUG] host https|api.spotify.com|443 has 1 conns, dropping oldest: Stream(RustlsStream)
[2024-03-26][00:43:24] [ureq::stream] [DEBUG] dropping stream: Stream(RustlsStream)
[2024-03-26][00:43:24] [ncspot::spotify_api] [ERROR] unhandled api error: json parse error: invalid type: null, expected a sequence at line 1 column 28815

Additional context Add any other context about the problem here.

OtaK commented 3 months ago

Related to https://github.com/ramsayleung/rspotify/issues/459

I managed to make it work by adding images to the playlists that didn't have one (I had a couple of very old - 2008 - empty playlists without pictures).

Brynyard commented 3 months ago

Any tricks to lure rspotify or ncspot to dump information about which if my 200+ playlists suddenly lack information without having to rewrite the code yourself?

OtaK commented 3 months ago

@Brynyard Nope. I just went through a similar number of them myself. It's pretty easy to spot anyway. Just go on the web interface, any playlist with no picture at all (the autogenerated ones are OK) is a culprit.

Brynyard commented 3 months ago

@OtaK No luck, gone through all my playlists and checked that they both have songs and an image.

Reading the original bug report in rspotify it is clear that there's a major SW architecture issue (and they don't even want to touch it - it's not failing on the devs setup), so it seems I'll be best of just adding a patch dumping the offending JSON and work around this issue.

wdoekes commented 3 months ago

@Brynyard : use ncspot --debug tmp.log and fetch a recent/valid Bearer token:

[2024-03-28][09:02:33] [rspotify_http::ureq]
  [INFO] Making request Request(GET https://api.spotify.com/v1/me/,
  [authorization: Bearer <THIS_TOKEN_HERE>])

Then curl the json yourself:

curl 'https://api.spotify.com/v1/me/playlists?limit=50&offset=0' \
  -H 'Authorization: Bearer <THIS_TOKEN_HERE>' 
  -o playlist.json

Then use the error (also in the debug log):

[ureq::unit] [DEBUG] response 200 to GET https://api.spotify.com/v1/me/playlists?offset=0&limit=50
...
[ERROR] unhandled api error: json parse error: invalid type: null, expected a sequence at line 1 column 3764

And look over there in playlist.json. I suspect it was this before editing:

...,"images":null,"name":"Soft Trance",...
                ^- 3764

After:

...,"images":[{"height":null,"url":"https://image-cdn-fa.spotifycdn.com/image/ab67706c0000da849b6028390071f2d6c163da0a","width":null}],"name":"Soft Trance",...
Brynyard commented 2 months ago

@wdoekes just adding a track didn't work, I had to explicitly upload an image to some of the playlists for this to go away.

wdoekes commented 2 months ago

I had to explicitly upload an image to some of the playlists for this to go away.

Nobody said anything about adding tracks. The fix was to add an image.

Brynyard commented 2 months ago

Nobody said anything about adding tracks. The fix was to add an image.

I read it as "playlist is missing image, make sure it has one", and the playlists in questions didn't have an image and got one (auto generated) when I added a track that I was sure was available. Apologies for not fully comprehending all the nuances of this quirk.

AndydeCleyre commented 2 months ago

I tried the curl in @wdoekes message, but my entire playlist.json is:

{"href":"https://api.spotify.com/v1/users/andydecleyre/playlists?offset=0&limit=50","limit":50,"next":null,"offset":0,"previous":null,"total":0,"items":[]}
AndydeCleyre commented 2 months ago

Well after a few relaunches ncspot told me to log in again, with something like "bytes were left on the stream," and after logging in again the playlists loaded.

neolight1010 commented 2 months ago

I'm experiencing this issue too.

SebastianErfort commented 2 months ago

My playlists weren't loading, but adding an image to a playlist without one fixed it for me. Thank you

HappyGoFishing commented 2 months ago

I have added images and it still doesnt load.

(EDIT) deleting my liked songs playlist fixed this.

jchusid commented 1 month ago

Related to ramsayleung/rspotify#459

I managed to make it work by adding images to the playlists that didn't have one (I had a couple of very old - 2008 - empty playlists without pictures).

Thanks for this advice. I had the same issue, I made sure there were images in every playlist and then the issue resolved.

hrkfdn commented 3 weeks ago

A new version of rspotify was released. I updated the one in main branch yesterday. Does it fix your problems?