This Python script downloads songs from a Spotify playlist by searching and downloading them from YouTube using yt-dlp. It utilizes the Spotify API to retrieve song details and yt-dlp to fetch and convert audio files from YouTube.
- Downloads all songs from a specified Spotify playlist
- Saves songs as high-quality MP3s (192 kbps)
- Organizes downloaded songs in a custom output folder
- No Spotify Premium Required!
- Python 3.x
- Spotify API credentials
yt-dlp
andspotipy
python libraries
- Clone the repository:
git clone https://github.com/SagnikGos/Spotify-Playlist-Downloader.git
cd Spotify-Playlist-Downloader
- Install Dependencies:
pip install yt-dlp spotipy
- Set Up Spotify API:
- Go to Spotify Developer Dashboard and create a new application.
- Copy the Client ID and Client Secret.
- Configure Output Folder:
- By default, the script saves downloaded songs to
./downloads
. You can change this in the script or through environment variables.
- By default, the script saves downloaded songs to
- Edit Configuration
- Make a
.env
file and set your Spotify Credentials, Playlist ID:
SPOTIPY_CLIENT_ID = 'YOUR_SPOTIPY_CLIENT_ID' SPOTIPY_CLIENT_SECRET = 'YOUR_SPOTIPY_CLIENT_SECRET' SPOTIPY_PLAYLIST_ID = 'YOUR_SPOTIFY_PLAYLIST_ID'
- Replace
YOUR_SPOTIPY_CLIENT_ID
,YOUR_SPOTIPY_CLIENT_SECRET
, andYOUR_SPOTIFY_PLAYLIST_ID
with your Spotify API credentials and playlist URL or ID. - Open
spotify-downloader.py
and setOUTPUT_DIR
to the folder where you want to save the downloaded songs.
OUTPUT_DIR = '/path/to/your/download/folder' # Change this to your desired output folder
- Make a
- Run the Script
- Once configured, simply run the script:
python spotify_downloader.py
- The script will:
- Fetch the song names and artist names from the Spotify playlist.
- Search each song on YouTube and download it as an MP3 in the specified output folder.
- Missing
yt-dlp
: Ensureyt-dlp
is installed. If not, install it withpip install yt-dlp
. - API Errors: Double-check your Spotify credentials in the script.
- Folder Permissions: Ensure that the specified output folder has write permissions.
This project is licensed under the MIT License.