问题描述:

I am building an app that needs to know if a track is playable in the user's region.

It's easy to check the basic territorial restrictions of a track using the Metadata API. However, I am encountering tracks that the Metadata API says are out of my region, but are auto-linked to versions of the same track that aren't region locked. ie. Metadata says I can't play a track, but as far as the user is concerned, Spotify can play that track.

Here's an example:

'Sweet Unrest' by Apparat @ spotify:track:4H4h3ulzjGVox14GHiCEoo

I am in the UK (territory code GB)

The lookup link is http://ws.spotify.com/lookup/1/.json?uri=spotify:track:4H4h3ulzjGVox14GHiCEoo

There is no GB code in the resulting territories string, so in theory, I should not be able to play the track. However, in the main Spotify player, I can see that it is auto linked to spotify:track:11S6TQybYumAnNApugZWSJ which is playable in my region. If I paste the supposedly unplayable track's URI into the top left Spotify search box, it plays.

Is there an API based way to check for tracks like this?

网友答案:

Unfortunately not, not at this time. The linking is actually done by the client itself rather than any of our backend services, so none of our APIs have this information.

网友答案:

You can detect whether a track is playable or not using an undocumented property of each track: data.availableForPlayback

Track.fromURI("spotify:track:XXX", function(track) {
alert(track.data.availableForPlayback);
});

If you run the code above, you should get a True/False that does what you're after.

相关阅读:
Top