possible spotify portrait metadata caching bug
Code to replicate
In my app I have the following code.var seed = "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"; sp.core.getMetadata(seed, { onSuccess: function (metadata) { console.log(metadata); }, onFailure: function () {} });
Steps to view the behaviour
Object name: "Whitesnake" portrait: "" type: "artist" uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP" __proto__: Object
Object name: "Whitesnake" portrait: "spotify:image:3c4aa30d845dd456d750cf16bef8e2cadb2af342" type: "artist" uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP" __proto__: Object
Object name: "Whitesnake" portrait: "" type: "artist" uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP" __proto__: Object
Question
Why is the radio app able to access a portrait uri that is then accessible from my app after using the radio app? Is there some sort of initialization, that needs to be done first or is this a bug?
Some information on an artist (and album, etc) isn't available until you do a "browse" on that URI - until then, Spotify only downloads basic information on an item to keep performance up.
What you're seeing is the Radio doing a browse, which causes the Spotify client to fill in the missing information.
An update to Spotify is coming soon that will improve this behaviour.
If I understood you correctly, you've noticed that after you get the result with a portrait URI from the radio, you get that object data populated when using it in your app?
On another note; you should be using the Artist class instead of sp.core.
var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
models.Artist.fromURI("spotify:artist:3UbyYnvNIT5DFXU4WgiGpP", function(album) {
console.log(album);
});
This should give you the correct output with a portrait uri string.
Artist
data: Object
name: "Whitesnake"
portrait: "spotify:image:3c4aa30d845dd456d750cf16bef8e2cadb2af342"
type: "artist"
uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
As iKenndac mentioned, try doing a 'browse':
var seed = "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP";
sp.core.browseUri(seed, {
onSuccess: function (metadata) {
console.log(metadata);
},
onFailure: function () {}
});
Examples here: https://github.com/ptrwtts/kitchensink
链接地址: http://www.djcxy.com/p/55542.html下一篇: 可能spotify肖像元数据缓存错误