Songs downloader for Spotify and Youtube.
Find a file
2025-09-27 14:22:21 +02:00
.github update readme 2025-08-13 00:30:30 +01:00
.gitignore init commit 2025-07-13 15:42:06 +01:00
functions.py fix 403 forbidden error, closes #2 2025-09-27 14:22:21 +02:00
LICENSE update README.md, add LICENSE 2025-07-13 16:48:48 +01:00
menu.py add ytmusic support 2025-09-14 01:02:48 +02:00
README.md update readme 2025-09-14 01:06:53 +02:00
requirements.txt v 2.0.0 2025-08-12 00:56:02 +01:00

SpotFetch :

SpotFetch Demo

A simple python program to download Music from various platfroms using yt-dlp ( The audio source is YouTube or YouTube Music depending on choice ).

What it can do :

  • Download Spotify playlists after exporting the playlist as a csv file from Exportify
  • Download your music library after exporting it as a csv file from TuneMyMusic, which supports a large number of platforms : Spotify, Deezer, Apple Music, Youtube Music, soundcloud, last.fm ... and much more, see the list here, but using Exportify is recommended since its opensourced and not commercial like TuneMyMusic.
  • You can also batch download music from a .txt file with URLs one by line.
  • Or batch download using a custom CSV file with headers name,artist
  • Direct download from a Youtube url, can be a video or playlist.
  • Search then download a song using its name and artist name.
  • Audio is downloaded as either MP3, M4A, or FLAC.
  • Song cover or thumbnail are always embedded, alongside numerous metadata.
  • You can use a cookie file in case YouTube rate limits your session.
  • You can download using either YouTube music or Youtube.

Installation :

Requirements :

  • First make sure you have ffmpeg installed on your machine Download here.
  • Make sure you have Python installed too, and is in your system path.
  • If you dont have Git to clone the repo thats fine, you can download it as a zip file and uncompress it, see here.

setup :

  • Clone this repository ( or just download it as a zip file and uncompress it ):
git clone https://github.com/MrElyazid/SpotFetch.git
  • then :
cd SpotFetch
  • Install requirements.txt ( preferably use a new virtual environement ):
pip install -r requirements.txt
  • Thats it, now run menu.py :
python3 menu.py
# or python menu.py
# or py menu.py

note :

It is recommended to use a virtual environement for SpotFetch since installing requirements globally on your machine is generally bad, before running pip install -r requirements.txt make sure you create and then activate a venv, and if on Windows and running powershell you might need to run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser before activating the venv.

Some details :

SpotFetch uses Rich for the Terminal UI, Mutagen for metadata handling when downloading using Exportify, and at its core its just a wrapper for yt-dlp.

why are only three audio formats supported ?

I will incrementally support formats that allow thumbnail embedding ( 'mp3', 'mkv', 'mka', 'ogg', 'opus', 'flac', 'm4a', 'mp4' ) and offer an option to download directly using yt-dlp's bestaudio format and fallback to m4a if the resulting format doesnt support thumbnail embedding ( F$ck WEBM !), when i tried this i had some issues especially with container formats like mp4, and also because if we want to embed Exportify metadata to these formats we need special handling for each one using mutagen, which is why i decided to stick with just :

  • MP3 : most compatible.
  • M4A : a mix between quality and compression.
  • FLAC : because its lossless.

How does the program set the best quality and bitrate ?

First off, YouTube uses adaptive streaming, the best available quality for a video can change depending on variables like the server load, location ... etc, to get the best available quality at the time of the request, the argument bestaudio for yt-dlp ensures we get the best quality available at the time of the download, and then comes the transcoding, when converting from the bestaudio format ( which is often opus or vorbis in WebM containers ) to mp3 or m4a the argument prefferedqyality: '0' is used, this ensures we dont produce a bloated transcode and perform VBR encoding instead of just setting the maximum bitrate which will just result in a large file size for the audio, note that for flac this last argument is ignored since the format is lossless.

in short : the best quality possible is always chosen.

Use the following extensions to get cookies for YouTube depending on your browser : Chrome, Firefox.

You can read more about using cookies with yt-dlp here

Download Platform Selection

You can choose between YouTube and YouTube Music for query-based downloads (e.g., search, CSV imports).

  • YouTube Music (default): Works best for popular songs and if you don't want to download video clip audio.
  • YouTube: Works best for niche and lesser-known songs and artists.

Configure this in the Settings menu (option 4).

How should the urls txt file look like ?

simply put each link in a line with no quotes, example :

https://youtu.be/dQw4w9WgXcQ?si=zQ_s7NhWcPgEQ46b
https://youtu.be/6-8E4Nirh9s?si=e7LKPptaE6vEEI48
https://music.youtube.com/watch?v=k-3y2LVF_SE&si=G2Dtl4LUbzjGIcpy

How should the custom CSV file look like ?

the headers are name,artist an example :

name,artist
"in the end","linkin park"
"under pressure","queen"
"time","pink floyd"

I keep getting 403 Forbidden Error :

If you get ERROR: unable to download video data: HTTP Error 403: Forbidden when trying to download, this is probably because yt-dlp needs to be updated, you can run pip install -r requirements.txt --upgrade to update it.

Also if using a venv, make sure you activate it before each launch of the app.

Using SpotFetch on Android :

since SpotFetch is just a python program, you can run it on any machine with python installed, you can run it on Android via Termux ( you can also find Termux on Google play ), after installation follow these commands :

  • Upgrade your system packages :
pkg update && pkg upgrade

Make sure to type Enter whenever needed while upgrading.

  • Install python, git, ffmpeg:
pkg install git python ffmpeg
  • Clone this repo :
git clone https://github.com/MrElyazid/SpotFetch
  • cd into the directory :
cd SpotFetch/
  • install the requirements:
pip install -r requirements.txt
  • Rotate Your phone : do it so that the terminal UI doesnt look awful :/

  • Run menu.py :

python menu.py

Thats it, after downloading try to locate where Termux stores files on your Android and access your downloaded files there.

Contributing :

If you have any enhancement ideas for the program or encountered a bug ( i didnt test it extensively ), you can submit an issue or a PR, happy to help!