Spotify doesn't have a playlist importer

So I made my own

The podcast “Uhh Yeah Dude” has interesting musical intros and outros, I wanted to have all these songs in a Spotify playlist. A fan of the show had maintained such a playlist until 2016, but more recent picks were missing. What to do?

Getting and transforming the data

The first step was scraping the UYD website to build a list of episodes–not too difficult! The code for this is kind of boring, but it’s on GitHub if you’re interested.

An episode of UYD:

{
  "date": "October 2nd 2010",
  "number": "Episode 238",
  "linkToNotes": "https://uhhyeahdude.com/index.php/show_notes/episode_238",
  "intro": "Collage // The Three Degrees",
  "outro": "John Cale and Terry Riley"
 },
 ...

The next step was transforming the list of episodes to a list of songs.

{ "title": "Collage", "artist": "The Three Degrees" },
{
  "title": "The Worst Band In The World",
  "artist": "10cc",
  "album": "Sheet Music"
},
...

Authenticating with the Spotify API

This would have been a lot more frustrating if I had not found Ari V’s implicit grant template.

Songs to URIs

Accomplishing this required writing some JS: songs-to-uris.

Spotify’s Web API can add songs to a playlist, but the method in question requires “track URIs”. So somehow, the list of songs must be converted to a list of URIs. The search api can be used to locate songs in Spotify’s catalogue, but the api returns a lot of unrelated songs. There does not seem to be any way of narrowing a search to a particular artist, culling unrelated results must be done manually.

Finding URIs for songs is the messiest part of all this. There are a number of reasons songs may end up missing:

It is also possible for false positives to sneak in (although this is not so likely due to the strict matching).

It didn’t work all that well, to be honest. Of the 600 songs fed into it, only about 250 URIs came out.

Adding songs to a playlist

More JS: uris-to-playlist.

If you have a list of URIs, this is simple. The only complication is that the add track api method only allows 100 songs to be added per call.

Minimum polish

The previously linked tools worked for me, but they are not polished.

Improvements that could be made:

Seatbelts…

For what it’s worth, the playlist is here and the data is here.