Spotify Apps API: Library Class Will Not Return Users Playlists

I am trying to get an array containing all the playlists in the user library (http://developer.spotify.com/download/spotify-apps-api/reference/dcdebc652c.html).

There are no problems with other class properties (albums, artists, starredPlaylist, tracks), but somehow the Playlists property will not work using

var allPlaylists = models.library.playlists; 

whereas

 var allArtists= models.library.artists; 

works just fine! (Both use document.write (var))

Any suggestions? thanks!

0
source share
3 answers

It seems to me that sp.core.library.getPlaylists is disabled. 0.8.0-701-gc2d793a

+1
source

Here is the official answer:

Unfortunately, the ability to get custom playlists in the Spotify Apps API has been removed for privacy reasons. This was done at the last minute, and the documentation was not updated on time. We will soon be releasing a new customer build and documentation that reflects this change.

+2
source

I think this is a bug with the API.

 sp = getSpotifyAPI(1); models = sp.require('sp://import/scripts/api/models') models.library.playlists; > TypeError: Cannot read property 'length' of undefined try { models.library.playlists } catch(err) { console.log(err.stack) } > TypeError: Cannot read property 'length' of undefined at map (sp:216:20) at Library.<anonymous> (eval at evalModule (sp:55:46)) at unknown source at Object._evaluateOn (unknown source) at Object._evaluateAndWrap (unknown source) at Object.evaluate (unknown source) 

Digging into the models.js file, we see that the library uses sp.core.library.getPlaylists () to get playlists that should return an array but return undefined:

 sp.core.library.getPlaylists() > undefined sp.core.library.getPlaylists > function getPlaylists() { [native code] } 

Since sp.core.library.getPlaylists is native code, I cannot go deeper into the rabbit hole to see what it does. Therefore, if spotify developers do not say that this is the desired behavior, my conclusion is that this is a mistake.

0
source

Source: https://habr.com/ru/post/1390218/


All Articles