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)
download it and put it in a folder you'll be able to find later (i use Escritorio/songs): download_songs.py
you need python 3, ffmpeg (it turns the audio into mp3) and two python libraries, yt-dlp and mutagen. pick your system:
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.
sudo apt update
sudo apt install python3-pip ffmpeg
python3 -m pip install yt-dlp mutagenwith homebrew installed:
brew install python ffmpeg
python3 -m pip install yt-dlp mutageninstall 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.
make a virtual environment and install there instead:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install yt-dlp mutagen.csv named after the playlist, for example mood.csvthe 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.
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.
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.
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.
No module named 'yt_dlp' or 'mutagen': redo the pip install from step 2File not found: run the command from the folder where the csv is, or give the full pathffmpeg: it's not installed, or it's the stripped down version. check step 2The track list is empty: the csv has no songs, or it's a web page that got saved by mistake. export it againFAILED: update the downloader with python3 -m pip install -U yt-dlpif anything breaks or doesn't work just ask claude or chat gpt i dont know
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 