CLI tool to download Spotify playlists, albums, and tracks with high-quality audio and complete metadata.
- π΅ Download individual tracks, playlists, or entire albums
- π¨ Automatic metadata embedding (artist, album, artwork, etc.)
- π High-quality audio (up to 320kbps MP3)
- β‘ Concurrent downloads for faster processing
- πΎ Smart caching to reduce API calls
- π Beautiful progress bars and real-time feedback
- π Secure credential management
- π Zero infrastructure cost - runs entirely on your machine
- π Encrypted Credentials: Your Spotify API credentials are now securely encrypted
- π Statistics Tracking: Track your download stats with
spotify-dl stats - π¨ Custom Templates: Name your files your way with
--template "{artist}/{album}/{track}" - π Dry-Run Mode: Preview downloads before committing with
--dry-run - π Duplicate Detection: Find and remove duplicates with
spotify-dl dedupe - β Better Testing: 75% code coverage with comprehensive tests
- π Performance: Enhanced caching and parallel download management
- π Structured Logging: Winston-based logging with rotation
- π Auto-Config: Browser opens automatically during
spotify-dl configsetup
- π¦ Bulk Download: Download multiple URLs at once or load them from a text file with
--file - β° Native Scheduling: Schedule recurring downloads using standard cron syntax (e.g.,
"0 0 * * *") - π» Background Daemon: Run the scheduler in the background with
--background- survives terminal closure! - π€ Playlist Export: Export any playlist or album to JSON or TXT format with
spotify-dl export - π Smart URL Resolution: Support for mobile share links (
spotify.link), short links (spoti.fi), and Spotify URIs
See CHANGELOG.md for full details.
-
Node.js (v18 or higher)
- Download from nodejs.org
- Verify:
node --version
-
FFmpeg (for audio conversion)
- Ubuntu/Debian:
sudo apt-get install ffmpeg - macOS:
brew install ffmpeg - Windows: Download from ffmpeg.org
- Verify:
ffmpeg -version
- Ubuntu/Debian:
- Go to Spotify Developer Dashboard
- Log in with your Spotify account
- Click "Create an App"
- Fill in the app details (name and description)
- Copy your Client ID and Client Secret
npm install -g spotify-music-downloader-cli# Clone the repository
git clone https://github.com/yourusername/spotify-cli.git
cd spotify-cli
# Install dependencies
npm install
# Link globally
npm linkRun the configuration wizard:
spotify-dl configOr view detailed setup instructions:
spotify-dl help-setupspotify-dl download https://open.spotify.com/track/3n3Ppam7vgaVa1iaRUc9Lpspotify-dl download https://open.spotify.com/playlist/44YDp4eCFJedE5QPRzGXPdspotify-dl download https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy# Specify output directory
spotify-dl download <url> -o ~/Music/Spotify
# Set audio quality (128, 192, 256, 320)
spotify-dl download <url> -q 320
# Adjust concurrent downloads (1-10)
spotify-dl download <url> -c 5
# Combine options
spotify-dl download <url> -o ./music -q 320 -c 3# Configuration & Setup
spotify-dl config # Configure Spotify API credentials
spotify-dl help-setup # Show detailed setup instructions
# Downloading (supports multiple URLs)
spotify-dl download <url1> [url2...] # Download tracks/playlists/albums
spotify-dl download --file urls.txt # Bulk download from a file
# Playlist Management
spotify-dl export <url> [output.json] # Export playlist/album tracks to file
spotify-dl stats # Show download statistics
spotify-dl dedupe <dir> # Find duplicate files
# Scheduling
spotify-dl schedule "0 0 * * *" <url> # Schedule download (cron syntax)
spotify-dl schedule "0 0 * * *" -f f.txt # Schedule bulk from file
# Utilities
spotify-dl clear-cache # Clear metadata cache
spotify-dl --version # Show version number
spotify-dl --help # Show help information# Basic options
spotify-dl download <url> -o ~/Music/Spotify # Custom output directory
spotify-dl download <url> -q 320 # Audio quality (128/192/256/320)
spotify-dl download <url> -c 5 # Concurrent downloads (1-10)
# Bulk download
spotify-dl download <url1> <url2> <url3> # Multiple URLs at once
spotify-dl download --file playlists.txt # Load URLs from a text file
# Scheduling (New in v1.1.2)
# Schedule a daily download at midnight in the background
spotify-dl schedule "0 0 * * *" https://open.spotify.com/playlist/... --background
# Management commands
spotify-dl schedule-status # Check if background task is running
spotify-dl schedule-stop # Stop the background taskThe --background flag spawns a detached process that survives terminal closure on Linux, macOS, and Windows. It does not require PM2 or any external process manager. Logs are kept at ~/.spotify-dl/schedule.log.
Note: The process will stop if the computer is restarted. For reboot-persistence, use your OS's native tools (crontab for Unix, Task Scheduler for Windows) pointing to the spotify-dl download command.
spotify-dl download --dry-run # Preview without downloading spotify-dl download --template "{artist} - {track}" # Custom filename template
## Architecture
The tool uses a client-side architecture that runs entirely on your machine:
User's Machine βββ Spotify API (metadata only - legal) βββ YouTube Search (find matching audio) βββ YouTube Download (audio stream) βββ FFmpeg (audio conversion) βββ ID3 Tagging (metadata embedding)
**Key Components:**
- **Spotify API Client**: Fetches track metadata (artist, album, artwork)
- **YouTube Downloader**: Searches and downloads matching audio
- **Audio Processor**: Converts to MP3 with FFmpeg
- **Metadata Embedder**: Embeds ID3 tags and album artwork
- **Rate Limiter**: Prevents API quota exhaustion
- **Cache System**: Reduces redundant API calls
> [!CAUTION]
> **LEGAL DISCLAIMER: PERSONAL & EDUCATIONAL USE ONLY**
>
> This tool is intended strictly for **educational purposes** and **personal use**.
> - It uses the Spotify API for metadata only.
> - Audio is sourced from third-party services (YouTube).
> - Downloading copyrighted material without permission may violate the Terms of Service of Spotify, YouTube, and your local copyright laws.
> - The developers of this tool assume **no liability** for any misuse or legal consequences arising from the use of this software.
> - **By using this tool, you agree to take full responsibility for your actions.**
## Troubleshooting
### FFmpeg Not Found
```bash
# Install FFmpeg first
# Ubuntu/Debian
sudo apt-get install ffmpeg
# macOS
brew install ffmpeg
# Windows - download from ffmpeg.org and add to PATH
- Verify your Client ID and Client Secret are correct
- Reconfigure:
spotify-dl config - Make sure your Spotify app is active in the developer dashboard
- Some videos may be geo-restricted or age-restricted
- The tool will skip failed downloads and continue with others
- Check logs in
~/.spotify-dl-logs/for details
- The tool implements smart rate limiting
- If you hit limits, wait a few minutes and try again
- Consider reducing concurrent downloads:
-c 2
- Config:
~/.spotify-dl/config.json - Cache:
~/.spotify-dl-cache/ - Logs:
~/.spotify-dl-logs/ - Downloads:
./downloads/(or custom path with-o)
-
Optimal Concurrent Downloads:
-c 3(default)- Too high may cause rate limiting
- Too low is slower
-
Audio Quality:
-q 320for best quality- 320kbps = highest quality
- 128kbps = smaller files, lower quality
-
Cache Usage:
- Cache is automatic
- Clear periodically:
spotify-dl clear-cache
-
Playlist Organization:
- Use separate output folders for different playlists
- Example:
-o ~/Music/Playlists/Workout
spotify-cli/
βββ bin/
β βββ cli.js # CLI entry point
βββ src/
β βββ commands/
β β βββ download.js # Download logic
β βββ core/
β β βββ spotify.js # Spotify API client
β β βββ youtube.js # YouTube downloader
β β βββ audio.js # FFmpeg processor
β β βββ metadata.js # ID3 tagger
β βββ utils/
β β βββ cache.js # Caching system
β β βββ config.js # Config management
β β βββ logger.js # Logging utility
β β βββ progress.js # Progress display
β β βββ rate-limiter.js # Rate limiting
β βββ index.js # Module exports
βββ package.json
βββ README.md
# Install dependencies
npm install
# Run CLI
node bin/cli.js download <url>
# Or use npm start
npm startMIT License - see LICENSE file for details
If you find this tool useful, please give it a star! β
Made with β€οΈ for music lovers