RepositoryPython
JayChen35

JayChen35/spotify-to-mp3-python

The simplest way to convert/download your Spotify playlist into MP3 files, using Python 3.

185stars
44forks
10issues
0views

Spotify to MP3 - Python

The simplest way to convert/download your Spotify playlist into MP3 files, using Python 3.

How To Use

This code is meant to be as simple and easy-to-use as possible. Despite this, there are some setup and usage steps (such as installing necessary packages) that are necessary for this code to work. Please read this section carefully.

1. Clone the respository

To clone this repoistory using Git, use

git clone https://github.com/JayChen35/spotify-to-mp3-python.git

If you aren't familiar with Git, navigate to the top-left of this page and find the green button labeled "Clone or download". Clicking this and then click "Download ZIP". Extract the contents of the downloaded .zip file.

Open a terminal session and navigate to this folder, using cd.

cd spotify-to-mp3-python/

2. Installing dependencies

We will be installing dependencies using pip, the official Python package manager. If you do not have pip, I'd recommend checking this thread to install it.

Copy and paste (and run) the following line in your terminal session to install all necessary packages.

pip install -r requirements.txt

3. Setting up Spotify

Unfortunately, I could not find a workaround for this step - it seems like we're forced to go through the Spotify API to fetch information about playlists. But, it doesn't take long at all.

Go to the Spotify dashboard. Log in. Once at the Dashboard, click the green button labeled "Create App". Don't worry - you're not signing up for anything or commiting to something from Spotify. Here, it really doesn't matter what you put for "App name" and "App description". For me, I just put "Testing" for both. Make sure to check both agreement boxes and click "Create".

You should see this:

Spotify App Screen

You will see the "Client ID" field on the left (it's redacted here). Copy and save your Client ID somewhere - you'll need it later. Click "Show client secret" under Client ID and it should show you another long list of characters. Also copy and save your Client Secret.

Next, we need your playlist URI. To do this, simply open Spotify, right-click on the playlist you want to download, hover over "Share", and click "Copy Spotify URI". It should look something like this: spotify:playlist:37i9dQZEVXbJiZcmkrIHGU. When inputting this into the script, make sure to only input the characters after "spotify:playlist:". So for this example, input 37i9dQZEVXbJiZcmkrIHGU. Save your URI somewhere handy.

Alternatively, you can find the URI as follows:

  1. Right-click on the playlist you want to download
  2. Click "Share"
  3. Click "Embed Playlist"
  4. Click "Show Code"
  5. The URI is the code between "https://open.spotify.com/embed/playlist/" and the first "?"

For example in this code snippet:

The code is 11cPCycyvvpL0MDLO648vE

4. Running

Running this script is straightforward. Simply run in your terminal session:

python3 spotify_to_mp3.py

If you run into an error saying something like "ffprobe or avprobe not found", check out this solution.

Also during/after the execution of the script , it may prompt saying press "Ctrl+C". Don’t worry and just do it and it resumes the further process and starts asking credentials.

If all goes well, you should see your playlist beginning to download in a folder with the same name. Enjoy!

Enhanced Spotify Playlist Downloader Script contains:

  • Added multiprocessing support for faster downloads.
  • Included functionality to download album art and embed it in MP3 files.
  • Improved error handling for better reliability.

Modifications

If you don't like inputting your Client ID, Client Secret, Username, and URI every time, you can edit lines 96-99 in spotify_to_mp3.py to set the respective variables into a string containing your credentials instead of prompting with input(). For example, line 98 would become

username = "YourUserName"

Debugging

This script was made in the better part of an afternoon and so it's not, by far, bug-free. Personally, I've run into no problems using this script on any of my playlists, however, your mileage may vary. The most promenant bug I've run into involves the youtube-search package not consistantly turning up results, and most of the time, the best solution is to simply try running the script again and giving it more chances to get the search right.

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
donnemartin/system-design-primer

Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.

379.9k
Sep 15, 2026
RepositoryPython
vinta/awesome-python

The definitive list that answers "I want to do X in Python, which tool should I use?"

338.6k
Nov 28, 2026
RepositoryPython
practical-tutorials/project-based-learning

Curated list of project-based tutorials

290.9k
Nov 30, 2026
RepositoryPython
TheAlgorithms/Python

All Algorithms implemented in Python

226.6k
Nov 13, 2026
RepositoryPython
yt-dlp/yt-dlp

A feature-rich command-line audio/video downloader

212.4k
Dec 2, 2026
RepositoryPython
521xueweihan/HelloGitHub

:octocat: 分享 GitHub 上有趣、入门级的开源项目。Share interesting, entry-level open source projects on GitHub.

192.6k
Nov 27, 2026
RepositoryPython
Significant-Gravitas/AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

188.2k
Nov 29, 2026
RepositoryPython
huggingface/transformers

🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

169.5k
Dec 1, 2026
RepositoryPython
harry0703/MoneyPrinterTurbo

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

147.3k
Dec 1, 2026