This script sorts your spotify playlist.
Sorting of the playlist follows these rules:
- Duplicate tracks will be removed.
- Tracks are sorted into groups of albums, that are ordered in the manner of the album.
- Albums are grouped by artist and release date. (Artist is determined from the album rather than the track)
- Artist groups are sorted depending on the first tracks appearance date on the playlist.
To automate this process, you may use any utility that you seem fit. The script has arguments that can so that it can automatically sort a playlist.
# Single playlist
python ./src/main.py --sort "playlist url here"
# Multiple playlists
python ./src/main.py --sort "playlist url here","another playlist url"
It executes the sorting with console output. Recommended tools for the automation process is pm2.
For some guidance on how to use pm2, see this
- Spotify API credentials (SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET)
- Get these by creating an application in the spotify developer portal
- Set the Redirect URI to http://localhost:8080
- Python 3
- Pip dependencies in the requirements.txt file
Create a config.json file where the executable is.
Insert the spotify client id and secret like this:
{
"SPOTIPY_CLIENT_ID": "INSERT CLIENT ID HERE",
"SPOTIPY_CLIENT_SECRET": "INSERT CLIENT SECRET HERE"
}
Install dependencies by running this command
pip install -r requirements.txt
Start the script by running
python ./src/main.py
There is an option to clone an existing playlist. This can be used to test the script before applying any permanent sorting to your original playlist.
You can also run the python script with --debug argument. This will not apply any changes to the playlist, and will instead print out the sorted playlist to terminal.
python ./src/main.py --debug