Migrating Playlists from Google to Spotify
I decided to switch to Spotify instead of Google Play Music. Spotify has a nice Linux client and an easy to use API. And moving my music away from Google helps to diversify the paid services I rely on, reducing my dependence on a single company.
Google doesn't offer a way to export playlists through the Google Play Music web application, and I don't like the idea of manually recreating my playlists in Spotify, so I used Firefox's developer tools to capture the relevant network responses and save my playlists that way. I then wrote a small script to import playlists using Spotify's API. Here's how it works.
Download Your Playlists from Google Play Music
For each playlist you want to export, first download it from the Google Play Music website.
- Load Google Play Music in your browser, open developer tools, and switch to the network tab.
- Navigate to the playlist in the web application.
- Switch to the developer tools network tab and locate the "loaduserplaylist" request for regular playlists or the "getephemthumbsup" request for the automatically created Thumbs Up playlist.
- Right-click on the request and select the option to copy the response.
- Paste the response into a new file.
Sign Up for a Spotify Developer Account
You'll need to sign up for a free Spotify developer account and create a new client ID. Make a note of your client ID and your client secret.
Next, generate an authorization token using the Spotify developer console. Click on the "Get Token" button in the "OAuth Token" section.
Finally, set the following environment variables using your client ID, client secret, and authorization token:
Run the Playlist Import Script
Download the playlist import script from
Make sure you have Node.js installed, then run
npm install within the project
directory, and then run the script once per playlist file with
node main.js <path-to-google-playlist-file>.
After the script runs, you'll have a new playlist in your Spotify account titled "Imported Playlist" containing each track that was successfully imported.
The script logs one line per track to standard out. Tracks that were successfully imported produce a line starting with "Added track". Tracks that were not imported produce a line starting with "Missing track" or "Error". You'll want to manually add these tracks.