iTunes Music - Import From Spotify
There are a lot of questions like this around the place, they all basically centre around "how can I (automatically) import my playlists from Spotify to iTunes Music"
I find it strange that Apple didn't release/include a tool for this, as it would be a good way to get people to switch. I personally wouldn't want to commit to iTunes Music (in preference to Spotify) without testing how well my Spotify playlists work.
One solution has been S.T.A.M.P (https://stampapp.io/) My understanding is it uses Automator and it is rather slow.
Another solution I have seen is Move To Apple Music By Ramon Frtisch (http://movetoapplemusic.ramonfritsch.com/) I have not tried this, so can't give you any details on it, or how good it is.
But, here is how I do it! I haven't built an app yet, planning on doing it, but haven't got around to it (and I just figured this out tonight!)
I will be working with a demo playlist, called iTunesSpotifyTest which I have created in Spotify, and contains one song - Midnight Oil's Blue Sky Mine from the album Blue Sky Mining. The Spotify URI for this track is: spotify:track:6z9ehfxE973fOlKJKNJL2x
Step 1: Export the list of tracks from Spotify. One way to do this (without the Spotify API) is to highlight all the tracks, and drag them to a text doc. You will get a bunch of Spotify URIs like http://open.spotify.com/track/6z9ehfxE973fOlKJKNJL2x
Step 2: Lookup the Spotify Track to get the track details: The basic URL to use is:
http://ws.spotify.com/lookup/1/.json?uri=spotify:track:<ID>
Where <ID> is the Spotify ID (6z9ehfxE973fOlKJKNJL2x) in this case
This will return a JSON reply like:
{"track": {"available": true, "album": {"released": "1990", "href": "spotify:album:4C3raKL0dzfTitM3YtqN1S", "name": "Blue Sky Mining (Remastered)"}, "name": "Blue Sky Mine - 2011 Remaster", "popularity": "0.31000", "external-ids": [{"type": "isrc", "id": "AUBM01100280"}], "length": 255.6, "href": "spotify:track:6z9ehfxE973fOlKJKNJL2x", "artists": [{"href": "spotify:artist:72KyoXzp0NOQij6OcmZUxk", "name": "Midnight Oil"}], "availability": {"territories": "AD AR AT AU BE BG BO BR CA CH CL CO CR CY CZ DE DK DO EC EE ES FI FR GB GR GT HK HN HR HU IE IS IT LI LT LU LV MC MT MX MY NI NL NO NZ PA PE PH PL PT PY RO SE SG SI SK SV TR TW US UY"}, "track-number": "1"}, "info": {"type": "track"}}
You could also use XML, but I think JSON is easier.
The fields we are interested in are:
track:album:name (Blue Sky Mining (Remastered))
track:name (Blue Sky Mine - 2011 Remaster)
track:artist:name (Midnight Oil)
Step 3: Lookup the track in iTunes
Use the URL Scheme found here : https://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web -service-search-api.htmlto build a search string. I am looking for artist+track+album of type musicTrack and media=music.
This URL needs to be encoded properly. I have found that it is easier to drop things like "Remastered" from the strings, thus our search terms become
Artist: Midnight Oil
Track: Blue Sky Mine
Album Blue Sky Mining
The final URL will be:
This will give a result (or number of results), such as this:
{ "resultCount":1, "results": [ {"wrapperType":"track", "kind":"song", "artistId":18747421, "collectionId":885256737, "trackId":885256765, "artistName":"Midnight Oil", "collectionName":"Blue Sky Mining (Remastered)", "trackName":"Blue Sky Mine", "collectionCensoredName":"Blue Sky Mining (Remastered)", "trackCensoredName":"Blue Sky Mine (2011 Remaster)", "artistViewUrl":"https://itunes.apple.com/us/artist/midnight-oil/id18747421?uo=4", "collectionViewUrl":"https://itunes.apple.com/us/album/blue-sky-mine-2011-remaster/id885256737?i=885256765&uo=4", "trackViewUrl":"https://itunes.apple.com/us/album/blue-sky-mine-2011-remaster/id885256737?i=885256765&uo=4", "previewUrl":"http://a1700.phobos.apple.com/us/r1000/024/Music4/v4/75/8b/9f/758b9fa4-fa2a-8187-3022-6c3978a309ec/mzaf_3480134139760267184.plus.aac.p.m4a", "artworkUrl30":"http://is3.mzstatic.com/image/pf/us/r30/Music2/v4/7b/26/7d/7b267d55-de38-f1af-ebd1-da8a986b2223/886444672726.30x30-50.jpg", "artworkUrl60":"http://is2.mzstatic.com/image/pf/us/r30/Music2/v4/7b/26/7d/7b267d55-de38-f1af-ebd1-da8a986b2223/886444672726.60x60-50.jpg", "artworkUrl100":"http://is1.mzstatic.com/image/pf/us/r30/Music2/v4/7b/26/7d/7b267d55-de38-f1af-ebd1-da8a986b2223/886444672726.100x100-75.jpg", "collectionPrice":8.99, "trackPrice":0.99, "releaseDate":"2014-06-10T07:00:00Z", "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":10, "trackNumber":1, "trackTimeMillis":255600, "country":"USA", "currency":"USD", "primaryGenreName":"Rock", "radioStationUrl":"https://itunes.apple.com/station/idra.885256765", "isStreamable":true}] }
Brilliant! We have found the song in iTunes.
Step 4: Build an iTunes Playlist file
If you want to see how this works, grab a playlist in iTunes, hit File->Library->Export Playlist, save it and open in a text editor. Turns out, not much is required to make a valid playlist file. The format we need is this:
Name | Artist | Composer | Album | Grouping | Genre | Size | Time | Disc Number | Disc Count | Track Number | Track Count | Year | Date Modified | Date Added | Bit Rate | Sample Rate | Volume Adjustment | Kind | Equalizer | Comments | Plays | Last Played | Skips | Last Skipped | My Rating | Location |
trackName<tab>artistName<tab><tab>collectionCensoredName<tab><tab><tab><tab>255<tab><tab><tab><tab><tab><tab><tab><tab><tab><tab><tab>AACaudio file<tab><tab><tab><tab><tab><tab><tab><nl>
This, from my experiments seems to be the requirements. Of course you can add more fields, but some are harder to work out than others, so why bother if they aren't required, right?
The first line is the header required, the fields are all tab delimited. It seems a "Time" value of 255 denotes a streaming file. Apart from that insert the right trackName, artistName and album (collectionCensoredName seems to work best), and type "AACaudio file" and your good to go. End the file with a new line. Then save the file as a .txt file with the file name equal to the playlist name.
In this case: iTunesSpotifyTest.txt
Name | Artist | Composer | Album | Grouping | Genre | Size | Time | Disc Number | Disc Count | Track Number | Track Count | Year | Date Modified | Date Added | Bit Rate | Sample Rate | Volume Adjustment | Kind | Equalizer | Comments | Plays | Last Played | Skips | Last Skipped | My Rating | Location |
Blue Sky Mine | Midnight Oil | Blue Sky Mining (Remastered) | 255 | AAC audio file | ||||||||||||||||||||||
Step 5: Import playlist to iTunes
File -> Library -> import and then select the file. Done!
This has worked brilliantly in my case, some things to think about
1) you might need to do some trial and error on removing words like "Remaster" etc
2) if you get multiple hits on the iTunes lookup, you will need to determine how to handle this (I just grab the first result for now, to do this in the URL lookup just add limit=1)
3) be careful with the playlist format, the right number of tabs, and finishing the file with an extra new line are required.
I have this at the moment in some crappy PHP code, I might (if there is enough interest) clean it up and release it on GitHub or something, but other than that, I hope this helps someone!
cheers!
Mac mini, OS X Mavericks (10.9.2), null