Export Spotify Playlist to CSV

14 Aug 2012



spotify



Today, I wanted to export my Spotify playlist to a classic CSV file. I needed it because I like to keep my data offline (we never know...).

Step 1: Google !  I found a couple of links like this one or that one but it was not what I was looking for. So...

Step 2: do it myself ! When you copy/paste HTTP URL (select all your songs and then right clik, copy HTTP URL) you got a big line with http uri. So I just did a "GET" on it to see what I got back.

It was an HTLM page with all the data that I wanted (title, artist and album name) so I wanted to parse that page.

To do that I used a great script "PHP Simple HTML DOM Parser" and I was able to get all the data needed !

You can get the source code here: https://bitbucket.org/matthieu_nantern/dlspotifydata/overview

It's very easy to use:
  1. Copy/paste your playlist in a text file, you have got a big ugly line and a text file called input.txt (for example...)
  2. Use the script: php -f dlSpotify.php input.txt output.csv
  3. Tadaaa ! output.csv is a CSV-file, with tabulation separation. Column 1 is the track title, Column 2 the artist(s) and Column 3 the album title.
Enjoy !