I’m developing a customized radio app for Spotify but I can’t understand it’s linking methods. I hope a Spotify developer can help me out here. For example:
I have an US account, so when I try to access the Spotify URI:
spotify:track:5rDsAMjmB4Qa5WNciJPsfK
This URI is forbidden, as you can see on the XML:
<track>
<id>b2ee21fccf6845e5a0d72a39bf7752b8</id>
<title>Tubthumping</title>
<artist-id>1d4211ecf9d04ffea26202e010042951</artist-id>
<artist>Chumbawamba</artist>
<album>Playlist: 90s Pop</album>
<album-id>da4ae29b497741bab15a97881ed1b70d</album-id>
<album-artist>Various Artists</album-artist>
<album-artist-id>19334eaffa3f4f2282e251e36611e26f</album-artist-id>
<year>2008</year>
<track-number>19</track-number>
<length>202706</length>
<files>
<file id="87cca4e0822573c3ee8a8a6a04c809b2db9935b6" format="Ogg Vorbis,320000,1,32,4" />
<file id="ac8d8ed1142988bc18df15ac1357990faf3f5afd" format="Ogg Vorbis,160000,1,32,4" />
<file id="c91d6743f49e49f703ce87cfcd5698eb81800a86" format="Ogg Vorbis,96000,1,32,4" />
<file id="94558701f427aff8d68f8149ac3e98e18365cc5f" format="MPEG 1 layer 3,320000,1,32,4" />
</files>
<cover>86bdd0faee722e65034207dd28ed5513f914ef44</cover>
<cover-small>145aaacf5ffb81e38e9e0be24ac9d993a6f31366</cover-small>
<cover-large>1cd206fb15d81dd3f6cde8dd59d89f94e1094104</cover-large>
<popularity>0.63630</popularity>
<restrictions>
<restriction forbidden="AF,AS,BM,CA,GL,GU,KG,MK,MM,MP,PM,PR,PS,UM,US,VA,VI" catalogues="free,daypass,premium"/>
</restrictions>
<external-ids>
<external-id type="isrc" id="DEA349700542" />
</external-ids>
</track>
It’s forbidden for US and there’s no alternative that is allowed. However, on the Spotify application this file is linked to:
spotify:track:2JLRcAkPB8JZIIohZarVTr
which I can play because the track is not forbidden for a US account, as per it’s XML:
<track>
<id>59f872aa124941ba8facbd3e13cd4ab9</id>
<title>Tubthumping - Radio Edit</title>
<artist-id>1d4211ecf9d04ffea26202e010042951</artist-id>
<artist>Chumbawamba</artist>
<album>All-Star Sports Jams</album>
<album-id>eb030df86f954de1b92630611f497c19</album-id>
<album-artist>Various Artists</album-artist>
<album-artist-id>19334eaffa3f4f2282e251e36611e26f</album-artist-id>
<year>2008</year>
<track-number>8</track-number>
<length>212013</length>
<files>
<file id="099ec6f8bf800e4800d550a99fac75a4ceea2a0a" format="Ogg Vorbis,320000,1,32,4" />
<file id="25965023befa68849e724df3687634060e4679c6" format="Ogg Vorbis,160000,1,32,4" />
<file id="a61e885fe2d2e15e2fe56c0a5111ecac975792b7" format="Ogg Vorbis,96000,1,32,4" />
<file id="0914380378738d8ae4aeba6379ac45dbcd98bc51" format="MPEG 1 layer 3,320000,1,32,4" />
</files>
<cover>2344306830097471b90afe32584677c436c6dc33</cover>
<cover-small>7697a938417a0c585d15dfc5ddd672871e222e5b</cover-small>
<cover-large>517849070de1b127323c7b920a9b4bd321507135</cover-large>
<popularity>0.45674</popularity>
<restrictions>
<restriction allowed="CA,US" catalogues="free,daypass,premium"/>
</restrictions>
<external-ids>
<external-id type="isrc" id="USUR19700191" />
</external-ids>
</track>
How are these two tracks linked to each other? They are the same song, but all the attributes are different, not even the title matches (notice the first is not listed as “Radio Edit”). I thought at first that they might be connected by it’s ISRC, but not even that matches.
For some tracks (which do share ISRC code), you would see an XML element called alternative in the XML above (which you are not supposed to be able to view, because it doesn’t come from a public API). The alternative element would include information about file ids and restrictions so the client could decide to play those files instead if possible.
However, as you have noticed, there are still a few tracks that are “the same track” with different ISRC codes. The Spotify clients (not all of them) currently tries to find them by doing a special search query (also not public) to try and find replacements. These queries are a bit expensive and not done every time a client finds an unplayable track. Because of that, the behavior is not very deterministic. Different users in the same country can sometimes play and sometimes not. Because of this, we are planning on removing this client side linking and moving all the alternative logic server side, but we have not yet done it.