Help needed to test Spotify plugin with Oauth

Another data point…

I had an idea this morning, we haven’t used all of our family memberships yet so I created a new account in our family plan. This account has never been used by anyone and has no favourites, no saved songs or artists and no playlist. Then I got a refreshToken for it, went into the web UI and created a single, brand new playlist with two songs in it based on just searching, not sharing anything with anyone in the other family accounts.

And it works. My playlists displays the playlist successfully and can play it. My recently played item shows the songs that I played, and so on.

So based on @chsims1’s observation, that they have a family account but no collaborative playlists, I wonder if it’s a factor of who is the account owner versus who is just a “regular” premium member. Maybe that explains the differences.

Anyway, I posted the log from that at pastebin.com/BXtct68h but it looks pretty bare. I’ll try some other debug stuff later on today, but at least now I’ve got a “working” and “not working” configuration to try out against each other. Or maybe this is enough to help you solve the problem, @skikirkwood, knowing the API and all.

Progress!

That’s awesome! I need to add pagination call to get more than 20 items from playlists, stay tuned…

Did you use the owner of the Spotify family account or one of the others? We’re trying to diagnose why the new plugin isn’t working for others.

Hey Joe, I was very skeptical following a collaborative playlist could be the source of the issue here. But I followed your collaborative playlist on Spotify - and all 3 of my Volumio systems stopped showing “My Playlists”! So that indeed is it. Worse though, we’re not getting any error back from the API call, and now I’ve unfollowed your playlist, and “My Playlists” is still broken for me. :slight_smile:

Ok, at least we have more info here, let me see what I can discover about what’s going on.

I’m the owner of family account, I use this account. And I have plus two one for my wife, and one for my son… :slight_smile:
Everithing i have done as You suggest : download index.js and inser instead of xxxx… my generated token …

This new update will show you your 50 most recent playlists:

github.com/skikirkwood/volumio- … y/index.js

Hey Joe, it took me all day on a sunny California Saturday, but think I got it! Try this update:

github.com/skikirkwood/volumio- … y/index.js

I believe the issue is some kind of obscure bug in the Node.js wrapper I’m using to the Spotify Web API. So for playlists I just directly called the Spotify Web API instead of the Node wrapper and got it working.

Still need to put in pagination, and block out local playlists, but appears to be working, with or without subscribing to your collaborative playlist. Let me know how it works for you and thanks for the help testing this!

I appreciate your sacrifice! :smiley:

Score! That did it. Now I’ve got access to all of the options both on my original account and on the one I just created today. Not all of my lists are showing up, but I gather that’s the pagination / 20 items thing you’ve mentioned here. So I think you’ve solved this one. Thanks a ton!

I’ll keep an eye on this one, though and see if there’s anything else I can help test out.

Still no ‘My Playlists’ here with latest ‘index.js.’ Is there any way of debugging/making spop more verbose? It’s difficult to see how to progress this otherwise with “info: Spotify credentials grant success.”

Hi,

Regarding latest update ( update will show you your 50 most recent) here are the observations :

53 playlists are shown,
100 items from playlists …

The funny thing is that ( for example) :

  • playlists list in volumio folow playlists from spotify android app , but …
  • “randomly” are missing some items - the list is not continous as in Spotify,
  • therefore the last playlists item in volumio is not the 53th playlist item in Spotify playlists list …
  • see below
    randmiss.jpg
  • My Saved Albums shows correctly saved albums, only 50, but correctly …
  • see below
    spotvsvol.jpg

Hi, I have tested the newest file now and it works better than before but it only shows 3 of 16 lists. But hey, that’s way better than none :slight_smile:. So thanks for your nice fixes [emoji4]

Well progress after a fashion; in my case it seems to be a problem with family membership and which account is used.

I made a new family member account, generated a refresh token etc., changed the settings in the plugin to the new account, and it worked fine … I had content in ‘My Playlists’ for this fictitious family member. Reversing the changes back, including a new token, to the owner account left me in my original situation with no ‘My Playlist’ content.

Edit: just tried my wife’s account and it worked fine there too.

Edit2: just gone back to my account, and I have two (not all) of my wife’s playlists, but none of mine :smiley:

Can you try this for the accounts not working properly.

I’m logging the result of the API call to get your playlists in the volumio log file - search for “Playlist result is:” After clicking on the My Playlists link can you take a look at what is logged. I should be logging an error result as well.

Go to the Spotify Web player (open.spotify.com) and click on the “Your Library” link in the left-hand nav. The browser-based player is using the same API I am, so you should be seeing exactly the same results in both Volumio and the browser player. Spotify’s desktop/mobile apps use different APIs then the web player.

And then finally, for an account not working properly or at all, go to:

developer.spotify.com/

Log in using the credentials of the account not working properly, click on “Web Console” and then “Playlists” to get you here:

developer.spotify.com/console/playlists/

Now click on the second API call (“v1/me/playlists”)

Click on “Get token”, authenticate with the problem account credentials, and then click on “Try it”. Now look at the JSON response in the right. That’s the same API call I am making (directly now, not using the Node wrapper). For a problem account, now plug in the access token (not refresh token) you get from the EC2 server I put up. Are the results any different between the Spotify Console generated access token and the one from our test server?

The good news is that the new version of the Spotify plugin is only using the old Libspotify-based spop app for playback and control. All metadata is now being retrieved through the new, supported Spotify Web API. The fact that Spotify turned off metadata access in the API but kept the run-time API endpoints active tells me they had to, for legacy reasons of supporting older hardware/software players. That’s great news for us.

Challenging testing this thing but we’ll definitely get it working!

Can you compare the results of viewing your playlists in Volumio to the Spotify Web player (open.spotify.com => My Playlists). Spotify’s desktop and mobile apps use different APIs then the Web player - we’re using the same API as the Web player, so in principle should be getting the same results. For example, the Web API doesn’t support playlist folders, so you don’t see them in the Web browser player like you do in the desktop/mobile apps.

To everyone that is helping test the new Spotify plugin - thanks! I just discovered the need to add two additional authorization scopes to access private and collaborative playlists. This might be why some of you were not seeing all of your playlists.

So can everyone get a new refresh token from here:

54.86.144.136:8888/

The latest version of the Spotify index.js file is here:

github.com/skikirkwood/volumio- … y/index.js

Please post your /var/log/volumio.log file should you see any issues, hopefully, we’re almost there!

Edit: in this latest version the refreshToken variable that needs editing is on line 451.

Just to confirm :
My Playlists from volumio now shows exactly the same list as Spotify, but still only the first 50 playlists … and maximum 100 songs in each …
I’d like to say THANK YOU, really nice and fast work …

Thanks for the confirmation! The max number of playlists you can ask for in a single API call is 50 - but I have 61 playlists. The call to get a playlist’s tracks defaults to 100, and I have one playlist with over 700 tracks.

So pagination is coming soon. :slight_smile:

Right, so I’m back too, just to confirm that I’m now seeing exactly what I would expect in my ‘My Playlists’ with the new refreshToken. I’ve got the first 50 playlists that show up when I look at my playlist list in the web UI. So things seem very good on my side.

And … latest version works! :smiley: :smiley: Well done for the effort of sorting that.

Just to confirm the answer to your earlier question about json output from the playlists call on the developer site, I didn’t go through it with a toothcomb, but it looks the same & the playlists are definitely there with both tokens.

Thanks again for all the hard work :wink:

Just tested new version here now and it worked great! Thanks for the fix :slight_smile:

Great news! Maybe I’ll read the API documentation next time before I attempt to use it. :slight_smile:

Adding the pagination should be pretty simple. Now we just need to figure out how to roll out a production version of this. At the very least, we can add the refresh token to the Spotify credentials form and save it that way, and have a link on that page that brings up a new browser window for the Oauth authentication.