Bryan Grohman

All Writing

Migrating Playlists from Google to Spotify

2019-01-19

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.

  1. Load Google Play Music in your browser, open developer tools, and switch to the network tab.
  2. Navigate to the playlist in the web application.
  3. 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.
  4. Right-click on the request and select the option to copy the response.
  5. 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:

SPOTIFY_PLAYLIST_IMPORTER_CLIENT_ID
SPOTIFY_PLAYLIST_IMPORTER_CLIENT_SECRET
SPOTIFY_PLAYLIST_IMPORTER_AUTH_TOKEN

Run the Playlist Import Script

Download the playlist import script from GitHub. 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.