Platforms come and go, and Spotify most likely wont be around forever. What would you do if you woke up tomorrow and Spotify was gone. I know I wouldn't be too happy, after spending countless hours carefully curating well over 200 playlists.
So, to save your playlists from being erased from the internet forever, lets create a small python script to back them up. This post outlines the steps to configue and a basic walkthrough of my spotify-playlist-backup project.
Spotify Developer Application
Before we can jump into the code we need to setup our own Spotify Developer Application. This will require you to have a Spotify account (a free account should work). Once logged in, create a new application and save the
CLIENT_SECRET for later. Make sure you set
http://localhost:3000/callback as a return url for your application.
Into the code
Clone the spotify-playlist-backup repo and create a new
.env file. Copy and paste in the following code snippet and replace the values with your configuration.
# .env file
# Values from your Spotify Developer Application
# Your Spotify Username
# Your Spotify Password
# Comma separated list of usernames of playlist authors.
# This allows you to back up other peoples playlists (that you follow) if you want.
# if left blank, all of your followed/created playlists will be backed up.
Run the script
Once you have setup the
.env file, you're ready to run the script.
This assumes you already have python installed.
Yes, it is that easy. After running the above script you will have a local copy of all your playlist data in beautiful
Github Action setup
Before your Github Action will run successfully, you must setup the above
.env variables correctly within the repo.
Make sure your fork is a private repository
Lets go one step further and set our Github Action to run once a week. By default, the CRON Job Github Action is disabled. To enable this within your repo, open the
.github/workflows/python-app.yml file and uncomment the schedule code block.
# scheduled to run each week at 3am on a Tuesday
- cron: '0 3 * * 2'
description: 'Log level'
You can use the crontab tool to calculate when and how often you want to run the Github Action.