possible spotify portrait metadata caching bug

南楼画角 提交于 2019-12-13 04:42:51

问题


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

  1. If spotify is already open close it and then reopen it, after opening spotify run the app and view the console Which displays as
Object
    name: "Whitesnake"
    portrait: ""
    type: "artist"
    uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
  __proto__: Object
  1. Then click on the radio app and create a station based on the the band Whitesnake.
  2. Rerun the original app and view the console output which will display.
Object
    name: "Whitesnake"
    portrait: "spotify:image:3c4aa30d845dd456d750cf16bef8e2cadb2af342"
    type: "artist"
    uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
  __proto__: Object
  1. Quit spotify and rerun the original application and view the console which will display
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?


回答1:


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.




回答2:


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"



回答3:


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



来源:https://stackoverflow.com/questions/8723471/possible-spotify-portrait-metadata-caching-bug

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