Creating a festival playlist on Spotify using python

The problem: You’re going to a festival with more bands than you could ever hope to see. You need a playlist with songs of all the bands playing so you can decide what to go and see and what to give a miss.

The solution: From a list of the artists, query the Spotify Search API with the artist name and save the URIs of the five most popular tracks returned by Spotify. Simples!

[Download script]

The code above is the function which you can pass each artist name to. It’s only a few more lines of code to feed a list of artists into the function and save a playlist list of tracks. I’ve deliberately saved more data than is needed for this task, as you never know when it will come in handy e.g. creating a script to query the playlist for all the artists that were successfully found.

Once you have all the URIs in a text file, with appropriate line breaks, you can drag this into the Spotify client and into a new playlist and they’ll magically become the tracks you want!

2 thoughts on “Creating a festival playlist on Spotify using python

  1. Interesting! But you should have the code in a textfile for download, having a hard time getting the indents correct to try it.

    1. Hi Patrik,
      Thanks for the feedback, I should really learn the trick to span the code over two lines, but for the mean time I’ve added the corrected script to a text file which you can download.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.