Download YT Playlist

Updated 2 weeks ago

Step by Step

(1) Create a .bat file with the following content:

@echo off
setlocal enabledelayedexpansion

set /p "playlistUrl=Enter YouTube playlist URL: "

if "%playlistUrl%"=="" (
    echo No URL provided. Exiting...
    pause
    exit /b 1
)

set "playlistUrl=!playlistUrl:music.youtube.com=www.youtube.com!"

set /p "preserveOrder=Do you want to preserve the playlist order? (y/n): "

if /i "%preserveOrder%"=="y" (
    set "outputTemplate=%%(playlist_index)02d_%%(title)s.%%(ext)s"
) else (
    set "outputTemplate=%%(title)s.%%(ext)s"
)

echo Downloading playlist: !playlistUrl!
yt-dlp --cookies cookies.txt -f bestaudio --extract-audio --audio-format mp3 --audio-quality 192k -o "!outputTemplate!" "!playlistUrl!"

echo All downloads finished!
pause

(2) Place the file inside the folder you want to download the playlist to.

(3) Run it!

Behaviour

The script will ask you for a playlist URL, and whether you want to preserve the playlist order or not.

If you say yes (y) to preserving order, songs will be prefixed with "01_", "02_"... in the order they appear in the playlist. This will make sPEAKer respect the order too. You don't have to worry about the numbers appearing in the track names either; sPEAKer will recognize the prefix and hide it.

It requires yt-dlp.exe to be in your PATH or be inside the same folder this script will be run from.

⚠️ Important ⚠️

Make sure to NOT include this .bat script or yt-dlp.exe in your Thunderstore package or it will be rejected.