Easily download Spotify playlists as MP3 files. Click below to get the project files, then extract the ZIP or TAR.GZ to your preferred folder using tools like WinRAR, 7-Zip, or your system's built-in extractor.
Download ZIP Download TAR.GZWant to explore the source code or contribute? Visit the GitHub repository.
This Python script allows you to download audio tracks from a Spotify playlist by extracting track
information via the Spotify API and sourcing the audio from YouTube using yt-dlp. The
downloaded audio is converted to high-quality MP3 format (320kbps) using FFmpeg.
spotipy, yt-dlp, requests.Follow these steps to set up the environment and run the script.
If you don't have Python installed:
Open a command prompt and run the following command to install the necessary libraries:
pip install spotipy yt-dlp requests
This will install:
spotipy: For interacting with the Spotify API.yt-dlp: For downloading from YouTube (a fork of youtube-dl with better
performance).requests: For handling HTTP requests (already included in many Python environments, but
installed for safety).FFmpeg is required for extracting and converting audio to MP3 format. Installation varies by operating system.
C:\ffmpeg.bin folder, e.g., C:\ffmpeg\bin.ffmpeg -version. You should see
version information./bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)".
brew install ffmpeg.ffmpeg -version.sudo apt update && sudo apt install ffmpeg.ffmpeg -version.Script Configuration for FFmpeg: In the script (playlist.py), update the
'ffmpeg_location' in ydl_opts to match your FFmpeg installation path if it's not
the default. For example:
r"C:\ffmpeg\bin"/usr/local/bin
or similar if required.playlist.py in a text editor and replace the placeholders:SPOTIFY_CLIENT_ID = "your_client_id_here"
SPOTIFY_CLIENT_SECRET = "your_client_secret_here"
.env file instead (not implemented in this basic script).
playlist.py in a directory of your choice.cd path/to/your/script/directory
python playlist.py
- If providing the playlist URL as an argument:
python playlist.py https://open.spotify.com/playlist/your_playlist_id
When you run the script:
https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M or
spotify:playlist:37i9dQZF1DXcBWIGoYBM5M). Skip this if provided as a command-line argument.
downloads folder).
Artist - Track Name.mp3 in the output
directory.Example Output Directory Structure:
downloads/
├── Track1.mp3 - Artist1
├── Track2.mp3 - Artist2
└── ...
time.sleep(5)).ydl_opts in the script for different audio
formats or quality.Feel free to fork this repository and submit pull requests for improvements, such as adding support for environment variables or better error handling. Visit the GitHub repository to get started.
This project is licensed under the MIT License. See LICENSE for details (create one if needed).