

SpotMusic - Python ScriptSpotMusic - Python Script
SpotMusic is an application which allows to download songs from your spotify playlist to your storage.
SpotMusic - Python Script
SpotMusic is an application which allows to download songs from your spotify playlist to your sto...
Overview
Hi, This is the software for downloading songs from Spotify. You can download song from your playlist or entire playlist in just one click. It comes with a login interface from spotify which will help you to login your spotify account into it.Â
I have used oath of spotify for login. You must know that you have to get the spotify client and secret key. You can easily get these keys from spotify. Just go to their website for developers
Save the key in .env files and then use loadenv and os.getenv() for accessing it.
HERE IS THE LINK:-https://developer.spotify.com/
Working of the Code:-
Spotify does not allow to download the songs to your storage. However, this code does not directly download the songs from spotify. It gets the song info using spotify api and then download it from youtube (as most of the spotify songs are available in youtube). It has it own disadvantages but it works. I used yt_dlp for this work.
You must install yt_dlp and ffmpeg before running the program ffmpeg is a fundamental requirement for yt_dlp to deal with sounds.Â
link:- https://ffmpeg.org/download.ht...Â
I have also made the GUI. I used customtkinter for GUI. So, it will work smoothly.
Login ,Logout , Download from playlist are some of the buttons are there.
I hope this code will be helpful for you.
Features
Key Components:
- GUI (
customtkinter
): The program has a clean and modern user interface that allows you to log in to your Spotify account, browse your playlists, and download songs. - API Integration:
- Spotify: It uses the
spotipy
library to authenticate your Spotify account, retrieve your playlists, and get track information (song title and artist). - YouTube: It uses
youtubesearchpython
to find the most relevant YouTube video for a given song and artist, andyt_dlp
to download the audio from that video.
- Spotify: It uses the
- Configuration Management: It automatically creates a
SpotMusic
folder in your user'sAppData
directory (on Windows) to store configuration and download path information. - Portability: The
resource_path
function suggests the program is intended to be packaged into a standalone executable using tools like PyInstaller.
Requirements
Requirements
Before you can use this program, you need to set up your environment and obtain API credentials.
1. Python Libraries
You must have the following Python libraries installed. You can install them using pip
, Python's package manager:
pip install customtkinter spotipy yt-dlp youtubesearchpython python-dotenv pillow requests
2. FFmpeg
This program requires FFmpeg, a free software project that handles multimedia files. yt-dlp
uses FFmpeg to convert the downloaded audio into an MP3 file.
You can download and install FFmpeg from the official website. The process varies depending on your operating system:
On Windows:
- Go to the FFmpeg download page.
- Follow the instructions to download a pre-built executable for Windows. A common source is the
gyan.dev
build. - Extract the downloaded ZIP file to a location on your computer, such as
C:FFmpeg
. - You must then add the
bin
folder (e.g.,C:FFmpegbin
) to your system's PATH environment variables. This allows the program to find the FFmpeg executable from any directory.
On macOS:
The easiest way to install FFmpeg is by using a package manager like Homebrew. If you don't have Homebrew installed, you can find the instructions on their official website.
Open your terminal and run the following command:
brew install ffmpeg
On Linux (Debian/Ubuntu):
Use your system's package manager to install FFmpeg. Open a terminal and run:
sudo apt update sudo apt install ffmpeg
3. Spotify Developer Account
You need a Spotify Developer account and API credentials to use the program. Follow these steps:
- Go to the Spotify Developer Dashboard.
- Log in with your Spotify account.
- Click "Create an app" and provide a name and description.
- Once the app is created, go to the "Settings" of your new app.
- Click "Edit Settings."
- In the "Redirect URIs" section, add a new URI. For this program, you can use
http://localhost:8888/callback
. - Save the settings.
- Now, on the app's main page, you will see the Client ID and Client Secret. Keep these handy.
4. .env
File
The program uses environment variables to securely store your Spotify credentials. You need to create a file named .env
in the same directory as the Python script.
Add the following lines to your .env
file, replacing the placeholder values with your own Client ID, Client Secret, and Redirect URI:
CLIENT_ID="YOUR_CLIENT_ID" CLIENT_SECRET="YOUR_CLIENT_SECRET" REDIRECT_URI="http://localhost:8888/callback"
Instructions
Once you have completed the setup, you are ready to use the program.
1. Running the Program
Navigate to the directory containing the SpotMusic.py
file in your terminal and run the following command:
python SpotMusic.py
A graphical window will appear.
2. Logging in to Spotify
To download songs from your playlists, you must log in. Click the "Login With Your Spotify Account" button. A web browser window will open, prompting you to log in to your Spotify account and grant permission to the application. After you grant permission, the program will log you in, and your username will be displayed on the main screen.
3. Downloading a Single Song
- On the main screen, enter a Spotify song link in the text box.
- Click the "Download this song" button. The program will find the song on YouTube and begin the download. A confirmation message will appear once it's complete.
4. Downloading from Your Playlist
- Click the "Download Songs from Your Playlist" button.
- A new screen will appear with a dropdown menu displaying all your Spotify playlists.
- Select a playlist from the dropdown. The program will display the playlist's cover art and the option to select individual songs.
- You can either select a specific song from the "Select a Song" dropdown to download it individually or click the "Download Full Playlist" button to download all songs from the selected playlist.
Category | Scripts & Code / Python |
First release | 14 September 2025 |
Last update | 14 September 2025 |
Tags | simple, Downloader, Music, Web, python, gui, spotify |