A lightweight Python tool that fetches any Spotify track, album, or playlist and downloads the audio in MP3 format via YouTube. Built using the Spotify Web API and yt-dlp, this tool offers a straightforward way to save your favorite music offline—no Spotify Premium required.
- Convert Spotify links (track, album, or playlist) to MP3
- Smart YouTube audio search via track name and artist
- Organizes downloads by folder for albums or playlists
- Automatically cleans file names to avoid OS conflicts
- FFMPEG post-processing for high-quality audio
- Python 3.7+
ffmpeginstalled and added to your system path- Spotify Developer credentials (client ID and secret)
- Required Python packages:
spotipyyt-dlp
# Clone the repository
git clone https://github.com/TBO22/spotify2mp3.git
cd spotify2mp3
# Install required Python packages
pip install -r requirements.txtYou also need to have ffmpeg installed:
- macOS:
brew install ffmpeg - Windows/Linux: Download from https://ffmpeg.org
-
Visit the Spotify Developer Dashboard.
-
Create a new app and copy the Client ID and Client Secret.
-
Create a
.envfile in the root of your project:SPOTIFY_CLIENT_ID=your_actual_client_id SPOTIFY_CLIENT_SECRET=your_actual_client_secret
Run the script and paste a Spotify track, album, or playlist URL when prompted:
python spotify2mp3.pyExample input:
Enter Spotify track, album or playlist URL: https://open.spotify.com/playlist/123abcXYZ
Downloads will be saved in a folder named after the album or playlist.
Spotify_Downloads/
│
├── Track Name 1.mp3
├── Track Name 2.mp3
└── ...
For albums or playlists, a new folder will be created using the name from Spotify metadata.
This tool is intended for educational and personal use only. Redistribution of copyrighted content may violate YouTube or Spotify's terms of service.