Spotify Playlist Downloader
A Python wrapper around SpotDL that reads Spotify playlist, album, or track links and downloads matching audio from YouTube Music. It uses Spotify metadata to tag downloaded files.
Important: This does not download Spotify's original audio or bypass Spotify DRM. Matches and available audio quality depend on the source. Use it only for music you have permission to download.
Features
- Downloads a Spotify playlist, album, or individual track by URL.
- Saves files as
Song Name.m4a(title-only filenames). - Uses SpotDL to embed supported metadata, including title, artist, album, release information, track number, and album artwork when available.
- Requests M4A output without a forced bitrate conversion.
- Scans for existing songs and attempts to refresh metadata.
Limitations: Two tracks with the same title may collide; the current script does not guarantee collision-safe filenames. --restrict strict can simplify filenames beyond removing invalid characters. Source tracks may be incorrectly matched, and M4A output is not necessarily lossless or compatible with every player. The script does not perform audio restoration or normalization.
Files
Save the companion Python script as spotify_downloader.py in a convenient folder. The instructions below assume that name. The README does not include the Python script itself.
Windows
- Install Python 3 from python.org and enable Add Python to PATH during installation (or use the Python launcher
py). - Open PowerShell and check:
py --version
- Install SpotDL and its dependencies:
py -m pip install --upgrade spotdl
py -m spotdl --download-ffmpeg
py -m spotdl --download-deno
- Navigate to the directory containing the script and run it:
cd "$HOME\Downloads"
py .\spotify_downloader.py
- Paste your Spotify playlist, album, or track URL when prompted. Press Enter to accept the default destination,
Music\Spotify Downloads, or type a custom path.
If py is not found, try python in its place. If pip reports an externally managed environment or permissions issue, use a virtual environment as described below.
Linux
- Install Python 3, pip, FFmpeg, and Deno (if available from your distribution's packages). Example for Debian/Ubuntu:
sudo apt update
sudo apt install python3 python3-venv python3-pip ffmpeg
- Create a virtual environment and install SpotDL:
python3 -m venv ~/.venvs/spotdl
~/.venvs/spotdl/bin/python -m pip install --upgrade pip spotdl
~/.venvs/spotdl/bin/python -m spotdl --download-deno
If the Deno helper command is unsupported by your installed SpotDL version, consult its current installation documentation. You may instead install Deno from its official distribution instructions.
- Run the script:
~/.venvs/spotdl/bin/python spotify_downloader.py
- Paste the Spotify URL and select a destination. The default is
~/Music/Spotify Downloads.
Other distributions: Use your package manager to install Python 3 and FFmpeg; then follow the same virtual-environment commands.
FreeBSD (including GhostBSD)
- Install Python, FFmpeg, and pip support:
sudo pkg update
sudo pkg install python3 py311-pip ffmpeg
Package names vary by FreeBSD release. If py311-pip is unavailable or your installed python3 is a different version, find the matching pip package with pkg search 'py*-pip', or use python3 -m ensurepip where supported. Verify with python3 -m pip --version.
- Create a virtual environment:
python3 -m venv "$HOME/.venvs/spotdl"
"$HOME/.venvs/spotdl/bin/python" -m pip install --upgrade pip spotdl
- Confirm FFmpeg is installed:
ffmpeg -version
SpotDL's YouTube backend may require Deno. If
denois available through your package repository, install it withsudo pkg install deno. Otherwise consult the current SpotDL and Deno documentation for supported FreeBSD installation options. Do not assumespotdl --download-denoworks on every FreeBSD architecture/version.Run:
"$HOME/.venvs/spotdl/bin/python" spotify_downloader.py
The default output is ~/Music/Spotify Downloads.
How to get a Spotify playlist URL
In Spotify, open the playlist, select Share, and choose Copy link to playlist. Paste that link into the program. The script also accepts Spotify album and individual track URLs.
Example session
SPOTIFY MUSIC LIBRARY DOWNLOADER
====================================
Spotify playlist URL: https://open.spotify.com/playlist/EXAMPLEID
Download directory [/home/user/Music/Spotify Downloads]:
Configuration:
Format: M4A
Filename: Song Name.m4a
Metadata: Spotify
Album art: Embedded
Duplicates: Existing files checked
Destination: /home/user/Music/Spotify Downloads
EXAMPLEID is a placeholder; use a real Spotify link.
Check metadata and cover art
Use a music player or tag editor (for example, MusicBrainz Picard, Kid3, or Mp3tag) to inspect the resulting files. You can also inspect tags with FFprobe:
ffprobe -v error -show_entries format_tags -of default=noprint_wrappers=1 "Song Name.m4a"
Cover art is embedded only when SpotDL successfully retrieves it. SpotDL's metadata support is not a guarantee that every field exists for every track.
Troubleshooting
| Problem | What to try |
|---|---|
No module named spotdl | Install SpotDL using the same Python interpreter that runs the script. |
ffmpeg not found | Install FFmpeg and ensure ffmpeg is on your PATH. |
| YouTube extraction errors | Update SpotDL and its dependencies; check whether Deno is required by your installed version. |
| Some songs are missing | Check the downloader's error output; tracks can be unavailable or incorrectly matched. |
| Cover art or artist tags are missing | Inspect with a tag editor and verify that Spotify metadata was available. |
| Same-title songs overwrite one another | Use a unique filename template (e.g. {artists} - {title}.{output-ext}) or add a collision-safe renaming step. |
| M4A won't play on an older device | Confirm the actual codec with ffprobe; re-encode only if needed for device compatibility. |
--scan-for-songs or other flag is rejected | Run python -m spotdl download --help; CLI flags may change between SpotDL versions. |
Updating
Use the same Python environment as installation:
python -m pip install --upgrade spotdl
On Windows, py -m pip install --upgrade spotdl is usually appropriate. On Linux and FreeBSD, use the Python executable inside ~/.venvs/spotdl.
Notes on audio quality
- The
--format m4a --bitrate disableoptions avoid requesting a specific bitrate, but do not guarantee that no conversion happens. - Renaming or converting lossy audio to FLAC does not make it lossless.
- Source quality and licensing are independent of Spotify's playlist metadata.