Open gsora opened 8 years ago
I'm definitely open to this type of improvement, given that we can figure out a nice way of representing it structurally. Are the artists/albums/songs for a user the same as those saved as part of playlists or something else? What I'm getting at is, that if it's a completely separate concept from playlists, it will probably not be possible since it is not exposed through the libspotify API.
"Your Music" tab is where a song goes if for example, while listening to the Spotify Radio a user press the "plus" button.
Every song added to "Your Music" can be added to a playlist, so there's definitely a relationship between a playlist and this view.
Doh, I'm afraid this function can't be implemented.
After a quick search, this blog post came up.
Basically, libspotify doesn't let the implementer access this kind of information...
That's a shame.
Yeah, I was afraid of that.
However! https://developer.spotify.com/web-api/endpoint-reference/ does expose the information, and I don't have any problem per se with using multiple API's to provide this feature, if necessary.
I probably won't be implementing this myself in the foreseeable future, but I'd gladly discuss a patch to include it, were one proposed.
Oh, it seems!
In particular, this endpoint could be useful for the implementation:
GET https://api.spotify.com/v1/me/tracks
As the documentation says, this returns some JSON containing a list of the saved tracks, maximum 50 per request.
It's possible to add an offset
per request, and the response itself tells us if there's any need to make another request of this type.
The items
object contains various information, including the track uri
, in this format:
spotify:track:XXXXXXXXXXXXXXXXXXXX
The only caveats might be how to get a OAuth token. Do libspotify uses the same type of authorization?
Right, so we could just materialize the various resources based on the URI, that should work.
I've never implemented OAuth myself, so I'm not sure how to do it, I'd need to look into that (might be a good opportunity for me to finally read up on OAuth as well ;)). libspotify simply lets you specify the username & password (and an API key) and takes care of the rest for you - notifying you of success/failure via callbacks. I'm not sure how it works beyond that.
Right now Spotify groups user's music under the "Your Music" tab.
A similar implementation could be useful, since not everyone keeps all of its preferred music in playlists.