Command line downloader for spotify tracks, playlists, albums and top artists songs. It works by taking the metadata out of these items using the Spotify API and searching them up on YouTube Music. Then, it downloads the result by using yt-dlp.
-
After having installed Python 3 with pip, you can install spotify-dlp using the following command:
pip install spotify-dlp
-
Then, login to Spotify developer console and click on "Create an App". Fill in details for name and description.
-
Make a note of Client ID and Client Secret. These values need to be then set to the
SPOTIFY_DLP_CLIENT_ID
andSPOTIFY_DLP_CLIENT_SECRET
environment variables respectivelyAlternatively, you can also include them in a
.env
file in the working directory, or even directly pass them as arguments.You can set environment variables by doing the following:
Windows (run in cmd as administrator):
setx SPOTIFY_DLP_CLIENT_ID "your_client_id"
setx SPOTIFY_DLP_CLIENT_SECRET "your_client_secret"
Linux (add to
~/.bashrc
):export SPOTIFY_DLP_CLIENT_ID="your_client_id" export SPOTIFY_DLP_CLIENT_SECRET="your_client_secret"
-
You can now use the script by running
spotify-dlp
in the command line. Also, ffmpeg is required if you wish to convert the m4a codec to another one using the-c
argument.
Command | Example | Description |
---|---|---|
"kon queso" | The words to search up or a link to a spotify album, artist, playlist or track. |
|
-i --client-id |
"qwertyuiop" | The Spotify Client ID*. |
-s --client-secret |
"asdfghjkl" | The Spotify Client Secret*. |
-f --format |
"{name} - {authors} ({album})" | The format of the downloaded tracks' names. Set to help for a list of available fields. |
-t --type |
"track" | When searching up a query, the specified type of content. |
-l --slice |
"2:6" | The beginning and ending index of the list items to download, separated by a colon ":" (1-based). Either one of those indexes can be omitted. |
-o --output |
"./album/" | The output path of the downloaded tracks. |
-c --codec |
"m4a" | The audio codec of the downloaded tracks. |
-m --metadata |
Whether to download metadata (such as covers). | |
-y --yes |
Whether to skip the confirmation prompt. | |
-v --verbose |
Whether to display verbose information. | |
-h --help |
Show the help message and exit. |
*Required if not already found in the environment variables or in the working directory .env
file.
spotify-dlp jigsaw falliing into place radiohead
spotify-dlp spirit phone -t album -o "%userprofile%\Desktop" -c mp3 -y
spotify-dlp https://open.spotify.com/album/2Vq0Y8wgiZRYtZ1mQ7zOMG -i "your_client_id" -s "your_client_secret"
This changelog only includes changes that are worth mentioning.
- 2.0.0:
- Basically, everything changed. Also added package to PyPI.- 2.0.1:
- Fixed--verbose
argument not working.
- Made youtube search more accurate.
- Better error handling.
- 2.0.1:
- 2.1.0:
- Added some QOL features.
- Fixed bug where a playlist with more than 100 tracks would be cut off.
- Better error handling.- 2.1.1:
- Fixed bug where track indexes would not show.
- Fixed bug where an album with more than 50 tracks would be cut off. - 2.1.2:
- Fixed bug where an error with a track would stop the whole process. - 2.1.3:
- Fixed bug where an already downloaded track would be downloaded again.
- Added colors to the output.
- Minor tweaks.
- 2.1.1:
- 2.2.0:
- Added--metadata
argument, which allows cover downloading.
- Fixed bug where a playlist with an episode in it would error out.
- Fixed bug where the -c argument would give files double extensions.