This makes a new Spotify playlist by pulling random songs from the artists connected to whatever source playlists you give it. It opens a simple GUI, lets you choose how many songs you want, and can optionally start playing the new playlist right away.
- Four random selection methods:
- random from the source playlists
- another track from the same album
- a top track from the same artist
- a track from that artist's wider discography
- Can skip tracks that already exist in your main playlists
- Can start playback immediately on an available Spotify device
- Opens the generated playlist in your browser and tries to open it in the desktop app too
- Uses a simple JSON config for playlists and app credentials
- Picks a random theme color on startup
- Python 3.x
- Spotipy (
pip install spotipy) - A Spotify Developer app
-
Create a Spotify developer app.
- Add a redirect URI like
http://localhost:8080/callback - Copy the client ID and client secret
- Add a redirect URI like
-
Copy
my_config.example.jsontomy_config.json. -
Fill in
my_config.json:{ "client_id": "YOUR_SPOTIFY_CLIENT_ID", "client_secret": "YOUR_SPOTIFY_CLIENT_SECRET", "redirect_uri": "http://localhost:8080/callback", "scope": "playlist-read-private playlist-modify-private user-read-private user-library-read user-modify-playback-state user-read-playback-state", "main_playlist_ids": [ "YOUR_MAIN_PLAYLIST_ID_1", "YOUR_MAIN_PLAYLIST_ID_2" ], "featured_playlists": [ { "id": "YOUR_FEATURED_PLAYLIST_ID", "name": "Some Playlist Name", "genres": "Short description" } ] }main_playlist_idsare your main playlistsfeatured_playlistsare optional extra playlists to generate from
-
Run it:
python SpotifyRandomizer.py
Or on Windows:
SpotifyRandomizer.bat
-
In the GUI:
- choose the number of songs
- decide whether to exclude songs from your main playlists
- decide whether playback should start immediately
- generate from your main playlists or one of the featured playlists
- It gathers tracks from the playlists you selected.
- Each song slot uses one of the random selection methods.
- If duplicate filtering is on, it skips anything already in your main playlists.
- It skips tracks that are not available in the US market.
- When the list is full, it creates a new private playlist and can start playback immediately.
- The app looks for
my_config.jsonand keeps Spotify token cache data inmy_token_cache.json, so both are ignored by Git. - If you want public playlists instead of private ones, change
public=Falsein the code. - Expect duplicates unless you turn on the main-playlist exclusion option.
- Some tracks get skipped if Spotify does not allow them in the US market.
- You need permission to read whatever playlists you use in your config.
