Spotify / Youtube offline downloads

Categorized as Blogging, Code, Software

I use spotdl which utilizes yt-dlp to download the actual songs. To download the highest quality you’ll need to have a Youtube Premium account with the audio quality set to high:

Next, you’ll need to get the cookies to authenticate, I personally use Chrome on windows, you’ll need to launch Chrome with the –disable-features=LockProfileCookieDatabase to avoid permission errors.

"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-features=LockProfileCookieDatabase

After Chrome has launched, use yt-dlp to get the cookies

yt-dlp --cookies-from-browser chrome --cookies cookies.txt

Once the cookies have been saved you can download the song at 256kbps bitrate by running the command:

spotdl --cookie-file cookies.txt <spotify_song_url>

A caveat using this method is that it will only work if a match is found on Youtube for the songs queried.

Alternatively I can download the audio track from a Youtube video directly with the following command:

yt-dlp --audio-quality 0 --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" --add-metadata --embed-thumbnail --metadata-from-title "%(artist)s - %(title)s" <youtube_url>

Leave a Reply