Introduction
This application takes advantage of the Spotify developer API to download the tracks in a playlist into a .mp3 format using YouTube. The downloader script first pulls the playlist from Spotify and saves them to a .csv file to store the values for later including Artist Album and year to be added to the file after by ffmpeg. Then it query’s YouTube via yt-dlp for the top result. The top result is then downloaded as a video in 1080p:271 and 320kbs (by default). This happens 5 times before ffmpeg is used to convert to audio and append the metadata along side the file. Then saved to the specified directory.

Features
One of the main features is the python based PyQt5 GUI that allows the user to configure the audio quality view a log as well as being able to select the output directory beforehand.
Libraries used
yt-dlp: Query YouTube and download tracks
ffmpeg: Manipulate media files and convert codecs as well as being used to append metadata to media files
PyQt5: GUI and custom styling
Usage
Clone repository
To start you have to clone the repository to get the latest version of the application
git clone https://git.rubenphagura.com/Spotify-Playlist-Downloader
Getting Spotify keys
- Sign into the Spotify developer site and create a new app.
- Once the app is created, copy your client ID and paste it into the
.envfile. - Click the button to show your client secret, then paste this string into the
.envfile. - Save the
.envfile and navigate to the project directory in file explorer or finder. - Double-click the
main.pyscript to run the app. - A window will appear; paste the playlist URL and press the download button.
Challenges
A key challenge in the development of this application was rate limits on yt-dlp/YouTube.
-
One way I attempted to remedy this issue was to split the download into chunks this was it would download 50 items at a time. This did not work as it used lots of memory and CPU while indexing and chunking sections of playlists over 100 tracks.
-
The final iteration of this fix was to pull the tracks and metadata and save then to a .csv file. Then the downloader.py would go 50 items at a time saving resources and also adding metadata as a bonus. Waiting 5 minutes between chunks.
Future Improvements
-
Support for other audio formats such as ACC FLAC and WAV may be added in a future version
-
Enhanced ability to download tracks with the same name so that they will not be overwritten with the newest file
Links and Resources
-
GitHub Repository: Spotify Playlist Downloader
Clone the repository to get started with the project. -
Spotify Developer API: Spotify for Developers
Learn more about the Spotify API used in this project. -
yt-dlp Documentation: yt-dlp GitHub
Explore the tool used for downloading YouTube videos. -
ffmpeg Documentation: ffmpeg.org
Understand the media manipulation library used for conversion and metadata. -
PyQt5 Documentation: PyQt5
Learn about the GUI framework used in the application.