UPDATE
Good news folks! Finally we managed to fix the Spotify plugin (and to revamp it a little…).
We implemented a cloud routine in Volumio which allows to execute OAUTH Authentication, and implemented this user flow in Volumio’s UI and Spotify plugin.
So, starting from version 2.0.0 (released today) no more tricks are required to access the library in full.
So, just install the plugin, follow the instructions and enjoy.
Thanks to Skirkwood, which lead the way to use Oauth and improved the plugin a lot, wihtout him this would not have been possible.
PS: To use Oauth functionality, Volumio version 2.671 is requred.
Hi All, Spotify shut off access to the “My Playlists” feature of (the deprecated) Libspotify last week. I’m experimenting to see if we can replace that feature with the new (and supported) Spotify Web API. Good news is it appears to work!
So to get this working you need to authenticate your Spotify account and get back a token that the Volumio can then use in API calls to access your personal playlists. Good news is the old Libspotify library appears to still work for audio playback, as there is no replacement yet.
So I could use some help testing the Proof of Concept I created. Here’s what you need to do:
First three people who help me test this will get first dibs on the v2 version under development - which has “My Albums”, “My Tracks” and “My Artists” - and yes, they are already working!
One imitation (probably due to a pagination feature in Spotify API), I can see only the first 100 songs of a playlist. the additional songs are not retrieved.
Sorry to report that nothing showing in ‘My Playlists.’
Pretty sure that I followed you instructions correctly, & no errors thrown in console (journalctl). The rest of Spotify in spop seems to work fine. Anything you want checking?
Not working for me… I used a windows tool called “winscp” to see if I placed the corrected file on my raspberry pi and it is there but “My playlists” is not working.
Yeah, also not working for me. Instead of copying files around I cloned the plugins repo to my local machine, made the change there and verified the change made it over to my pi:
skynet plugins/music_service/spotify$ git br
master
* oauth
skynet plugins/music_service/spotify$ git status
On branch oauth
Your branch is up-to-date with 'origin/oauth'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: index.js
no changes added to commit (use "git add" and/or "git commit -a")
skynet plugins/music_service/spotify$ ssh volumio@victor 'grep -A3 "Refresh token below" /data/plugins/music_service/spop/index.js'
volumio@victor's password:
X11 forwarding request failed on channel 0
// Plug in your Spotify Refresh token below - not the access token - the refresh token!
var refreshToken = '<actual refresh token removed but verified to be the same as the one on the page at http://54.86.144.136:8888/';
skynet plugins/music_service/spotify$
Still the same behaviour as before, though, nothing happening when I select My Playlists, but the others (Featured etc.) seem fine. Anything I can do to help debug this on my side?
Quick follow-up. I uninstalled my existing spop plugin with the Volumio UI, rebooted, re-installed and copied over the index.js file again. Now I’m seeing this in my logs when I attempt to re-enter my account information:
2018-06-01T15:23:26.961Z - info: CALLMETHOD: music_service spop saveSpotifyAccount [object Object]
2018-06-01T15:23:26.970Z - info: CoreCommandRouter::executeOnPlugin: spop , saveSpotifyAccount
2018-06-01T15:23:27.452Z - info: mDNS: Found device james-Volumio
2018-06-01T15:23:27.888Z - info: SpopD Daemon Started
2018-06-01T15:23:32.898Z - info: Connecting to daemon
2018-06-01T15:23:32.955Z - info: CoreCommandRouter::volumioAddToBrowseSources[object Object]
2018-06-01T15:23:32.966Z - info: [1527866612959] CoreMusicLibrary::Adding element Spotify
2018-06-01T15:23:33.025Z - info: FIRST BRANCH
2018-06-01T15:23:33.350Z - info: Spotify credentials grant failed with WebapiError: Bad Request
I then went back to the unmodified plugin and I’m able to log back in to my account successfully (though obviously without access to My Playlists). FWIW, I did try with the previous token and a newly created one from 54.86.144.136:8888
Hmmm, looks like my first release is working for 1/4 people. It continues to work across all 3 of my Volumio systems today. Let me try to follow my own instructions on one of my Pi’s and see if I can find what the issue is.
For those of you who tried it and did not get it working, can you post your /var/log/volumio.log file. I can see for one person the actual Spotify credentials grant failed, so that’s progress.
Okay, going back to try to start from a clean slate, so I uninstalled the Spotify (spop) plugin, rebooted, then installed it and configured it with my account details. So I’m starting from a pristine plugin that lets me log in and view the Featured, etc. items but not my playlists.
Then I rebooted the pi again and verified the index.js still had the correct token. After that, the volumio.log shows from boot until I click on the ‘My Playlists’ item. No error this time, it seems, but also no success on showing the page. And interestingly maybe, the error I saw before is gone when I went back to reconfigure the Spotify plugin with my username and password again. That was fine this time. So I don’t know what happened in the middle there. That log is here: pastebin.com/d1kccmAT
One last thing, though, when I was looking at the code I noticed there was a mix of tabs and spaces in the newly added stuff. It doesn’t seem to impact anything here, but I cleaned that up anyway: pastebin.com/agE1T8cv
Thanks for uploading that. Odd, you were able to successfully get a new access token:
2018-06-01T17:58:31.171Z - info: New access token = BQBHGQM5e4AXQH9FAxNZQ8Mdl1Vehrjz4aOBZ-_m_l-ey96pc_OKQZjUqoIBnAAXWyVWrYYE0MccnQoKkypxLWhB42rtplkwIsM6-QGCC-7Wql1oQeGu7F3TBC57kPL…
2018-06-01T17:58:31.173Z - info: Spotify credentials grant success
I’ll play around this afternoon. The strange this is I copied the updated index.js file to three of my Pi’s and it’s working on all of them, so there must be some kind of configuration issue I’m missing.
I’ve added support to browse your saved albums, tracks and favorite artists. You will want to grab a new refresh token as the API requests behind these require additional permissions from Spotify.
No idea if this is helpful or not, but I grabbed the version that enables albums/artists/tracks and those all work for me. Still no joy on the ‘My Playlists’ option and the logs are not terribly illuminating:
Thanks Joe. I’m still stumped why only 1/4 testers got the new plugin working. I just added a bunch of new features and it’s working great on all 3 of my Pi’s. Next step is I’ll uninstall the plugin, reinstall, then copy over the new index.js file and see what happens there.
Still no clue why 3/4 testers had trouble here, but in the mean time, we have new features! Added “My Saved Albums”, “My Saved Tracks”, “My Top Artists”, “My Top Tracks” and “My Recently Played Tracks”. These views make Spotify much more fun to play with on Volumio.
I wonder if it’s an account related thing. I have a Premium for Family account. My account (the one I’m using on Victor, my Volumio install) is the owner but there are four other active accounts, one for each of the family members. Another possibility is we have a few collaborative playlists shared between our accounts. So maybe there’s some unexpected atom coming back in the results when you make your API call.
Don’t know, just throwing out ideas there and suggesting ways my account may be different than yours.
And paste in your new refresh token. After you do that, let me know if any of the new views worked - there’s a bunch of them. And after doing that upload your log file.
I used to have a family account but reverted to a single user premium account. I just uninstalled the Spotify plugin one one of my Pi’s, reinstalled it, then copied the new Spotify index.js file over and everything is working. So perhaps it is the type of account.
Okay, so I gave that a shot. Got a new token, rebooted and things are somewhat better now, I think. I still don’t have access to my playlists, I click on that option and nothing happens, but all of the others work for me now (you can probably see in the log I rifled through all of the options the played a song out of my recently played list).
So, I guess there’s two possibly distinct things to test here. If it is the family versus single premium account, it sounds like I or someone else with a family membership will have to be more involved in looking at the root cause. But the other possibility is maybe it’s just the presence of collaborative playlists in the ‘my playlist’ set. If you don’t have any collaborative lists in your setup, that might explain the difference. I know in both the desktop and mobile UIs the collaborative lists get decorated differently. So if you think that’s maybe an option worth investigating, I’ve made this playlist open.spotify.com/user/joeythesa … MwifBJkQKg and specifically flagged it as collaborative. So even though I created it you should be able to edit it. Might be worth checking quickly if you can add it to your playlists and see if the option starts failing for you as well.
Anwyay, I’ll be checking in occasionally this weekend, so if there’s other stuff to try out, I’ll be happy to give it a shot.