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

后端 未结 3 1786
南方客
南方客 2021-01-17 01:27

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 prob

3条回答
  •  攒了一身酷
    2021-01-17 02:09

    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. (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.

提交回复
热议问题