This is a Python program that grabs songs from an Apple Music Playlist and adds them to a Spotify playlist through Spotify's web API.
How it works: The program's execution can be divided in 4 distinct steps:
- Grab songs and their corresponding artist names from the Apple Music playlist on web.
- Use Spotify's GET/search API to recieve a catalogue of search results.
- Find the song within the search results and retrieve it's unique ID.
- Send a POST 'Add items to Playlist' request to Spotify.
To get started:
- Enter your Apple Music playlist URL in main.py.
- Enter your Spotify playlist ID in main.py.
- Head over to the Spotify API docs (https://developer.spotify.com/console/post-playlist-tracks/) and create your OAuth Token.
- Set the Spotify API params and your generated Token in main.py.
- Run!
Note:
Not all songs are successfully found/added to Spotify. One reason could be that Spotify simply doesn't have the song in its library.
Another, more common one, is that the songs' names do not match 1-to-1 across platforms. For example: Apple may have a song as "Song X
(feat Artist Y)", while Spotify may have it simply as "Song X". To account for this, the songs' and artists' names are edited down prior
to search to find the closest match between strings. This can still sometimes result in songs not being found in Spotify.
In these instances, debug statements are added to print out the songs that weren't added. From my tests with playlists containing 200+
songs in multiple languages, only about ~5-10 songs failed to be added.