spotify-dl
Spotify Downloader and alternative of Spotdl(python) tool made in NodeJS based on youtube-dl
Top Related Projects
Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
Quick Overview
spotify-dl is a command-line tool for downloading Spotify songs, playlists, and albums. It uses the Spotify API to fetch track information and then searches for and downloads the corresponding audio files from YouTube. This tool is designed for personal use and offers a convenient way to save Spotify content for offline listening.
Pros
- Easy to use command-line interface for downloading Spotify content
- Supports downloading individual tracks, entire playlists, and albums
- Provides options for audio quality and metadata tagging
- Cross-platform compatibility (Windows, macOS, Linux)
Cons
- Potential legal issues due to downloading copyrighted content
- Relies on YouTube as a source, which may not always have the exact audio match
- Download speed can be affected by YouTube's limitations and network conditions
- May require frequent updates to maintain compatibility with Spotify and YouTube APIs
Code Examples
# Download a single track
spotify-dl https://open.spotify.com/track/1234567890abcdef
# Download an entire playlist
spotify-dl https://open.spotify.com/playlist/1234567890abcdef
# Download an album with high quality audio
spotify-dl -q high https://open.spotify.com/album/1234567890abcdef
Getting Started
-
Install spotify-dl using pip:
pip install spotify-dl
-
Set up your Spotify API credentials:
- Go to the Spotify Developer Dashboard and create a new app
- Set the environment variables:
export SPOTIPY_CLIENT_ID='your-client-id' export SPOTIPY_CLIENT_SECRET='your-client-secret'
-
Run spotify-dl with a Spotify URL:
spotify-dl https://open.spotify.com/track/1234567890abcdef
Note: Make sure you have ffmpeg installed on your system for audio conversion.
Competitor Comparisons
Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
Pros of spotify-downloader
- More active development with frequent updates and bug fixes
- Supports downloading entire albums, playlists, and artist discographies
- Offers a web UI for easier use by non-technical users
Cons of spotify-downloader
- Slower download speeds compared to spotify-dl
- More complex installation process with additional dependencies
- Larger codebase, potentially making it harder to contribute or modify
Code Comparison
spotify-downloader:
def download_track(track: Track) -> None:
song = Song.from_track(track)
download_url = song.download_url
if download_url:
song.download()
else:
logger.error(f"Could not find a download URL for {track.name}")
spotify-dl:
async def download_track(track):
song_name = f"{track['artists'][0]['name']} - {track['name']}"
query = f"{song_name} audio"
video_link = await get_youtube_link(query)
if video_link:
await download_audio(video_link, song_name)
else:
print(f"Could not find a download link for {song_name}")
Both projects aim to download music from Spotify, but spotify-downloader offers more features and active development, while spotify-dl provides a simpler codebase and potentially faster downloads. The code snippets show different approaches to track downloading, with spotify-downloader using a more object-oriented style and spotify-dl utilizing asynchronous functions.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Spotify Downloader
Download audio files from spotify links(Based on: youtube-dl)
Required
Get FFMPEG
git not windows or git for windows
Note: if you run into issues related to puppeteer chromium download please try PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install -g spotify-dl
spotifydl
A simple commandline utility that allows you to download Spotify Songs, Shows, Episodes, Playlists and Albums from Youtube.
PLEASE NOTE:
- The ability to find a video is dependent on the fact it is hosted on youtube, and even then there is a chance it is still incorrectly matched
- Some items may only be available to spotify premium users, please be sure to provide a username and password when this is the case
Installation
NPM
npm install -g https://github.com/swapnilsoni1999/spotify-dl
or You can do manually
git clone https://github.com/SwapnilSoni1999/spotify-dl
cd spotify-dl
npm install
npm link
Android (Termux)
PS: You may need to type termux-setup-storage
first and allow storage permission
sh -c "$(curl -fsSL https://raw.githubusercontent.com/SwapnilSoni1999/spotify-dl/master/tools/termux.sh)"
Docker
docker run ghcr.io/swapnilsoni1999/spotify-dl
or Build docker image:
git clone https://github.com/SwapnilSoni1999/spotify-dl
cd spotify-dl
docker build -t spotify-dl .
Usage
To download highest quality audio file
spotifydl <spotify track/album/playlist link> ...
Example
spotifydl https://open.spotify.com/track/xyz
Options
Flag | Long Flag | Usage |
---|---|---|
--o | --output | takes valid output path argument |
--es | --extra-search | takes extra search string/term to be used for youtube search |
--oo | --output-only | enforces all downloaded songs in the output dir |
--sf | --search-format | provide template for youtube api, supports albumName , artistName ,itemName |
"something {itemName} - {albumName} anyrandomextrastring" | ||
--of | --output-format | provide template for output of filenames, supports albumName , artistName ,itemName |
3 x _ are used to signify directories | ||
"something___{artistName}{albumName}{itemName}" | ||
--ef | --exclusion-filters | comma separated string of exclusion filters |
each filter will be checked against the description and title if found the link will be ignored | ||
--st | --saved-tracks | download spotify saved tracks |
--ss | --saved-songs | download spotify saved shows |
--sp | --saved-playlists | download spotify saved playlists |
--sa | --saved-albums | download spotify saved albums |
--l | --login | Requests a login in an external window (non tty should use --u and --p) (Docker without -it is non tty) |
--u | --username | spotify username for headless long (Note: you must use --login once to grant access) |
--p | --password | spotify password |
--cf | --cache-file | takes valid output file name path argument |
--dr | --download-report | output a download report of what files failed |
--cof | --cookie-file | takes valid file name path argument to a txt file for youtube cookies |
--v | --version | returns current version |
--h | --help | outputs help text |
--dl | --download-lyrics | enables downloading of lyrics |
--oft | --output-file-type | choose which type of file to be output as |
Notes
To use --u and --p (headless login) you must do a --l once first to grant required permissions (playlists, saved songs ect.)
if you receive 'Got a spotify api error WebapiRegularError: An error occurred while communicating with Spotify's Web API
Details: non existing id' you may need to provide auth either use --l
for manual login prompt or --u username --p password
for headless login
If you receive a 429 error please provide a cookies file given the --cof
flag, to generate a cookies file please refer to Chrome or Firefox
Docker
docker run -it --user=$(id -u):$(id -g) -v $(pwd):/download --rm spotify-dl <options-to-spotify-dl defaults to --help>
docker run -it --user=$(id -u):$(id -g) -v $(pwd):/download --rm spotify-dl "https://open.spotify.com/...."
Acknowledgements
thanks to icons8 for icons in hero image and all the contributors for PR, suggestions and testing :love:
License
MIT © Swapnil Soni
Top Related Projects
Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot