Addie and I have created a large playlist of all the tunes we currently like.
Oftentimes, we will want to put on a mood - currently either bops
or softs
.
Bops are for when things are good. The kids call them bangers. Think a boisterous Friday evening.
Softs are for when things are mellow. The kids call them chill tunes. Think a hungover sleepy Saturday morning.
There was no way for us to put on one mood of songs we currently like. We had to skip softs when we were in a bop mood and bops when we were in a soft mood.
Enter Spotify Splitter.
Spotify Splitter splits a large playlist into bops
and softs
based on a separation algorithm.
Spotify characterizes all of their songs with various criteria called Audio Features.
Using these, we can run each song through a filter to determine if it is a bop, a soft, both, or neither.
A rudimentary, pseudocode filter may look like:
if song['danceability'] > 0.7:
bops.add(song)
if song['energy'] < 0.45:
softs.add(song)
The current sorting algorithm can be found on the spotify-splitter.py file.
To run this on your own playlists:
- Go to your Spotify for Developers Dashboard (SfDD).
- Create an account if needed.
- Create a new app and call it "Spotify Splitter."
- Edit the "Spotify Splitter" app's settings and add an entry to "Redirect URIs":
http://localhost:8080/
. Be sure to save! - Create a
.env
in the basespotify-splitter/
folder with the following environment variables:
SPOTIFY_CLIENT_ID
: your client id from the SfDDSPOTIFY_CLIENT_SECRET
: your client secret from the SfDDSPOTIFY_REDIRECT_URI
:http://localhost:8080/
SPOTIFY_USER
: your spotify username, as written on your Spotify Account pageMAIN_PLAYLIST_ID
: the playlist id to split; you can find it on the Spotify Web Client in the url:https://open.spotify.com/playlist/<playlist_id>
- Curate the sorting algorithm to your liking. Refer to the Audio Features page for more sorting criteria.
- Change the
Playlist
objects' initialization (playlist_name
) to your liking. - Run the
spotify-splitter.py
script. - You may choose to run this on a cron job in order to keep updating your playlists on a regular basis. We run ours daily at midnight.
You will have to authorize your Spotify account on first run.
Enjoy your split music!