3

If I am based in the US and I want to play the song "Sun" by Two Door Cinema Club I would use the ID 544390857. I can do this in (for example) the systemMusicPlayer and the song begins to play in Apple Music.

If my friend is based in the UK and wants to play the same song, sending 544390857to the systemMusicPlayer results in the song not being recognised (and nothing played).

The GB storefront equivalent ID for that song is 674900368.

I have two questions:

  • Is there an easy way of me being able to play the ID from another storefront in Apple Music (using systemMusicPlayer) or would I have to repeat the search under the new, second storefront ID?

  • or, is there a way of taking one song ID (i.e. the US one) and exchanging it for the alternative (i.e. GB) one?

Thanks for any help you can give!

scgough
  • 5,099
  • 3
  • 30
  • 48
  • I know this is not what you exactly want, but I wanted to share it as it is kind of related. There is a way to make iTunes links storefrontid-independent: https://affiliate.itunes.apple.com/resources/documentation/apple-music-best-practices-for-app-developers/‌ If you are just linking to music you can prepend a “geo” prefix to any link and we will route the user to the right content in their region so you do not have to worry about finding the right ID. Example geo aware link structure: https://geo.itunes.apple.com/us/album/if-youre-reading-this-its/id966997496 – Bahri Okuroglu Aug 18 '17 at 11:56
  • @BahriOkuroglu thanks for that. I had thought of using the `geo.` link to help me get to my destination but it wouldn't be true to a user's base storefront if (for example) they were travelling to another country. – scgough Aug 18 '17 at 12:04
  • My impression was that the "geo" prefix is making sure Apple Music is showing correct content for the user's storefrontid. I verified it with my non-US Apple Music subscriptions and US-only songId. Unfortunately I could not find a way to play the correct songId, fixed for user's storefrontid. – Bahri Okuroglu Aug 18 '17 at 12:38
  • @BahriOkuroglu when you request that `geo.` prefixed URL I'm making the assumption that Apple use your IP address (as there is nothing else to go on) to determine the location to provide the song for...so that IP wouldn't be true to the user's base/native storefront ID. – scgough Aug 18 '17 at 12:41

3 Answers3

2

You could try to use Apple Music API to get the right info:

(Step 1 is only needed if you don't know the song name in advance, you only know the songIds)

  1. Based on the storeFrontCountryCode ('US') and songId (matched to that 'US' store) you can get the songName ("Sun"), using 'Get song' API call.

  2. You need to retrieve the user current storeFront. You can do it with requestStorefrontCountryCodeWithCompletionHandler)

    You would get something like "GB".

  3. With the songName ('Sun') and the user storeFrontCountryCode ('GB') we do a 'Search for catalog resources' to get the right song id.

Eventually to prevent issues with duplicated song names, you could add the artist name to the 'Search for catalog resources' api call.

Community
  • 1
  • 1
Xavi A.
  • 755
  • 1
  • 6
  • 12
  • Absolutely, I agree this is a way it can be done (suggested in my OP) but I was looking for a sure-fire way of determining the equivalent song in another territory. As it stands this would only be a 'fuzzy' match rather than like-for-like. If storefront licensing comes into play then it adds a further spanner in the works. I was hoping for a link Apple's side for songs in different territories. – scgough May 11 '18 at 13:19
1

You can use isrc property of the song to filter a search for song id in another region. From the returned list you can then compare which one is the most match.(ie. a song may appears in multiple albums and has different edits).

The first step would be query the isrc property of the song in the original region. For example:

GET https://api.music.apple.com/v1/catalog/us/songs/544390857

Then you will have the isrc string in the attributes dictionary, then query it in GB storefront:

GET https://api.music.apple.com/v1/catalog/gb/songs?filter[isrc]=XXXXXX

This method is much more accurate than search by song name + artist name.

The Doc link is here: Apple Music API

AMGuru
  • 106
  • 1
  • 3
  • Sorry for the late reply on this. I like this solution a lot. I'm presuming all songs would have an IRSC value attached to them? What if it isn't available? – scgough Apr 08 '19 at 10:40
  • For now I have not encounter the case of missing IRSC but I won't presume that because for music Metabase everything is possible. So if IRSC is missing there should be a way to fall back to the more tedious song name+artist search method. – AMGuru Apr 08 '19 at 16:19
1

I think this is the API you're looking for:

Get Equivalent Catalog Songs by ID

Germán
  • 4,525
  • 3
  • 31
  • 37