Ana Sayfa / Kod ve Scriptler / SpotMusic - Python Script

SpotMusic - Python Script

SpotMusic, Spotify çalma listenizdeki şarkıları depolama alanınıza indirmenizi sağlayan bir uygulamadır.

  • Yayın tarihi14 Eylül 2025
  • Son güncelleme17 Eylül 2025
SpotMusic - Python Script

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, and yt_dlp to download the audio from that video.
  • Configuration Management: It automatically creates a SpotMusic folder in your user's AppData 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:

  1. Go to the FFmpeg download page.
  2. Follow the instructions to download a pre-built executable for Windows. A common source is the gyan.dev build.
  3. Extract the downloaded ZIP file to a location on your computer, such as C:FFmpeg.
  4. 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:

  1. Go to the Spotify Developer Dashboard.
  2. Log in with your Spotify account.
  3. Click "Create an app" and provide a name and description.
  4. Once the app is created, go to the "Settings" of your new app.
  5. Click "Edit Settings."
  6. In the "Redirect URIs" section, add a new URI. For this program, you can use http://localhost:8888/callback.
  7. Save the settings.
  8. 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"