Spotify Apps API: Library-class won't return users Playlists

一个人想着一个人 提交于 2019-12-01 12:26:38

问题


I'm trying to get an array containing all Playlists in the users Library (http://developer.spotify.com/download/spotify-apps-api/reference/dcdebc652c.html).

No problems with the other class properties (albums, artists, starredPlaylist, tracks), but somehow the "Playlists" property won't work using

var allPlaylists = models.library.playlists;

whereas

var allArtists= models.library.artists;

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

Any suggestions? thank you!


回答1:


Here's the official answer:

Unfortunately, the ability to get the user's playlists in the Spotify Apps API has been removed for privacy reasons. This was done very last-minute, and the documentation wasn't updated in time. We'll be releasing a new build of the client and documentation that reflects this change soon.




回答2:


I looks like sp.core.library.getPlaylists got disabled in . 0.8.0–701-gc2d793a




回答3:


I'm thinking it's 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 in the models.js file we see that Library uses sp.core.library.getPlaylists() to get the playlists, which should return an Array but returns undefined:

sp.core.library.getPlaylists()

> undefined

sp.core.library.getPlaylists

> function getPlaylists() { [native code] }

Since sp.core.library.getPlaylists is native code I am unable to go deeper down the rabbit hole to see what it is doing. So unless the spotify devs say it is the desired behaviour my conclusion is that it is a bug.



来源:https://stackoverflow.com/questions/8627627/spotify-apps-api-library-class-wont-return-users-playlists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!