A high-quality music downloader that fetches tracks from a Spotify album or playlist and downloads the best matching audio using yt-dlp and Spotipy.
This project allows you to:
- Input a Spotify album or playlist URL.
- Retrieve detailed track information from Spotify.
- Search and download the best matching audio from YouTube.
- Output audio in FLAC format with advanced postprocessing options.
- Spotify Integration: Retrieve album or playlist data using Spotify’s API.
- YouTube Search & Download: Leverage yt-dlp to search for and download high-quality audio.
- Custom Audio Conversion: Converts audio files to FLAC using FFmpeg with user-specified settings.
Set up a virtual environment to manage your project’s dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateCreate a requirements.txt file (if it doesn't exist) with the following content:
echo "yt-dlp" > requirements.txt
echo "spotipy" >> requirements.txtThen install the dependencies:
pip install -r requirements.txtThe script requires Spotify API credentials to retrieve track data. To obtain these credentials, follow these steps:
-
Visit the Spotify Developer Dashboard.
-
Log in with your Spotify account.
-
Click on "Create an App".
-
Fill in the App Name and App Description, then agree to the terms.
-
Once your app is created, you will see the Client ID and Client Secret.
-
Open the file
spotify_version_Download_High_quality_songs.pyand replace the placeholders:SPOTIFY_CLIENT_ID = 'ENTER_SPOTIFY_CLIENT_ID' SPOTIFY_CLIENT_SECRET = 'ENTER_SPOTIFY_CLIENT_SECRET'
with your actual Client ID and Client Secret.
Ensure that FFmpeg is installed and available in your system's PATH:
- Download FFmpeg from ffmpeg.org/download.html.
- Follow the installation instructions for your operating system.
- Verify the installation by running:
ffmpeg -versionTo run the Spotify downloader script, execute the following command in your terminal:
python BeatHarvest.pyYou will be prompted for:
- Spotify URL: Enter the URL of the Spotify album or playlist.
- Output Directory: Specify the folder where the audio files will be saved (or press Enter to use the current directory).
-
Spotify API Errors:
Double-check your Spotify credentials to ensure they are correctly set in the script. -
yt-dlp Issues:
Verify that yt-dlp is updated to the latest version. -
FFmpeg Not Found:
Confirm that FFmpeg is properly installed and added to your PATH. -
General Errors:
If you encounter any other issues, review the error messages in your terminal. They can often provide clues on what might be misconfigured or missing.
Contributions are welcome! Feel free to fork the repository and submit pull requests. For major changes, please open an issue first to discuss your ideas.