Null or undefined artist images with Spotify Apps API
I am having trouble geting artist images in the Spotify Apps API. The image property of the Artist object is mostly returning as null or undefined. This is the case whether I get the artist directly from a collection of artists (such as from sp.core.library.getArtists()) or if I use Artist.fromURI and use a callback function.
Here is an example of the sort of thing I am doing:
var m = sp.require('sp://import/scripts/api/models');
var a = m.Artist.fromURI(uri, function(artist) {
console.log(artist.name + " " + artist.image);
});
Looking in the console I see the artist name, but a null or undefined image.
Sometimes if I start Spotify and go to the artists page before starting my app, the image will be populated but later it will become null again.
Am I missing anything, or could this be a bug in the API?
The solution is that spotify seems to have just some artist pictures. If you query the api, it is true that there is no artist picture. But if you browser the artist page, spotify has implemented an own fallback to query for a album picture as artist picture. This picture is then saved as the artists picture, for caching reasons. So the solution might be to do the same and query an album picture as fallback.
Using the sp.core method is not recommended, as someone at spotify told me in irc.
[edit] Also, if you use the sp.core it seems that you get error messages in your console like 'Application xxx is not allowed to yyy'
链接地址: http://www.djcxy.com/p/55540.html上一篇: 可能spotify肖像元数据缓存错误