A collection of Python scripts to export Spotify playlists and download them as MP3s, along with various utilities for managing your local music library.
This project primarily relies on the spotdl library for downloading and the spotipy library for interacting with the Spotify Web API.
Important
Due to changes in the Spotify Web API, you must have a Spotify Premium account to use these scripts.
https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security
git clone https://github.com/mithulpranav24/Spotify-To-MP3.git
cd Spotify-To-MP3It is not absolutely necessary, but it is recommended to use a virtual environment because the dependencies can get quite messy.
python -m venv venvActivate it:
- Windows:
venv\Scripts\activate - macOS/Linux:
source venv/bin/activate
pip install -r requirements.txtEnsure you have ffmpeg installed and on PATH. If you don't have ffmpeg then install it using:
spotdl --download-ffmpeg- Go to the Spotify Developer Dashboard and create a new app.
- In the app settings, set a Redirect URI (e.g.,
http://localhost:8888/callback). - Create a
.envfile in the root directory of this project and add your credentials:
client_id='your_client_id'
client_secret='your_client_secret'
redirect_uri='your_redirect_uri'-
get_spotify_playlists.pyConnects to your Spotify account to fetch all your playlists and exports their Name, URL, and URI into aspotify_playlists.csvfile. -
Usage:
python get_spotify_playlists.py
-
download_playlist.pyReads thespotify_playlists.csvfile and prompts you to select which playlists you'd like to download. It then usesspotdlto download the selected playlists into aplaylists/directory. -
Usage:
python download_playlist.py
If your MP3 player has issues with displaying artist names correctly / lyrics / track numbers, try using one of these:
-
misc/artist.pyCleans up artist tags in audio files (MP3 and FLAC). It splits multiple artists separated by commas, semicolons, or slashes into a list format and sets the album artist to 'Various Artists'. Usage:python misc/artist.py <path_to_music_folder>
-
misc/check_unique.pyCompares two Spotify playlists (A and B) and deletes any duplicate tracks found in Playlist B (i.e., songs that are also in Playlist A). Great for maintaining a unique playlist. Usage:python misc/check_unique.py <playlist_a_url> <playlist_b_url> --confirm
-
misc/count_m3u.pyCounts the number of valid song entries in one or more.m3uplaylist files. Usage:python misc/count_m3u.py <path_to_m3u_file_or_directory>
-
misc/metadata_modifier.pyScans a music folder and cleans up the artist names in the metadata by replacing slashes (/) with commas (,) across various audio formats (MP3, FLAC, M4A, etc.). Usage:python misc/metadata_modifier.py <path_to_music_folder>
-
misc/remove_track_number.pyRemoves track number (TRCK) metadata from all MP3 files within a given directory. Useful for cleaning up a library if you prefer not to have track numbers. Usage:python misc/remove_track_number.py <path_to_music_folder>
-
misc/strip_lyrics.pyThoroughly removes lyrics from your music library. It deletes any external.lrcfiles and strips embedded lyric tags (like USLT/SYLT) directly from MP3 files. Usage:python misc/strip_lyrics.py <path_to_music_folder>