VinVentolin's trash can

💉Spotify playlist to mp3💉

Overview

ok so this is a python script that takes a playlist exported from spotify (a csv file), looks every song up on youtube and saves it as an mp3 with its title, artist and album tags. everything runs on your own computer, and you don't need a spotify developer account or premium for any of it.
(written on fedora, so the windows and mac instructions are less tested. should work the same, ymmv)


1 Get the script

download it and put it in a folder you'll be able to find later (i use Escritorio/songs): download_songs.py


2 Install the stuff

you need python 3, ffmpeg (it turns the audio into mp3) and two python libraries, yt-dlp and mutagen. pick your system:


2.1 Fedora

fedora ships a stripped down ffmpeg, so you have to enable rpm fusion and swap it for the full one:

sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
      sudo dnf swap ffmpeg-free ffmpeg --allowerasing
      python3 -m pip install yt-dlp mutagen

if ffmpeg-free isn't installed on your system, use sudo dnf install ffmpeg instead of the swap.


2.2 Ubuntu / Debian

sudo apt update
      sudo apt install python3-pip ffmpeg
      python3 -m pip install yt-dlp mutagen

2.3 macOS

with homebrew installed:

brew install python ffmpeg
      python3 -m pip install yt-dlp mutagen

2.4 Windows

install python from python.org (tick "add python to PATH"), then in powershell:

winget install Gyan.FFmpeg
      py -m pip install yt-dlp mutagen

close and reopen powershell so it finds ffmpeg. on windows use py wherever this page says python3.


2.4.1 pip says externally-managed-environment?

make a virtual environment and install there instead:

python3 -m venv venv
      source venv/bin/activate
      python3 -m pip install yt-dlp mutagen

3 Export your playlist

  1. go to exportify.app and log in with your spotify account
  2. hit the export button next to the playlist you want (or "export all")
  3. you get a .csv named after the playlist, for example mood.csv
  4. move it to the same folder as the script

the script knows the column names in english and spanish. if your spotify is set to another language it will print the columns it found and stop, and you'll have to add them to tracks_from_csv in the script.


3.1 No csv?

a plain .txt also works, one song per line written as Artist - Title. handy if exportify doesn't work for you. the csv gives better results though, because it includes the length of every song and the script uses it to pick the right youtube video.


4 Run it

open a terminal in the folder with the script and the csv and run:

python3 download_songs.py mood.csv

change mood.csv to whatever your file is called. if there's only one csv in the folder you can skip the name and just run python3 download_songs.py.
it prints the progress song by song and saves everything in a folder named after your file:

mood.csv  ->  ~/Escritorio/songs/mood/
      gym.txt   ->  ~/Escritorio/songs/gym/

if you run it again, songs that are already downloaded get skipped, so you can just repeat it if something fails halfway.


4.1 Changing the destination

open the script in any text editor and edit the OUT_BASE line at the top. if your system is in english your desktop is called Desktop, not Escritorio.


5 If it breaks


if anything breaks or doesn't work just ask claude or chat gpt i dont know

6 Stuff you should know


about me

monster addict with an irrational love for science (mostly biochem, ochem and electronics) and cat enthusiast born in 2006 in a spanish village lost from the hand of god

full width section

half width section

half width section