Created
August 26, 2022 16:15
-
-
Save milnak/deaf6c02ef0a867b8547d8a172a13c23 to your computer and use it in GitHub Desktop.
Download playlists or channels from youtube using yt-dlp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
REM Set codepage to UTF-8 | |
chcp 65001 > NUL | |
echo. | |
REM Hidden ESC character on next line. | |
set ESC= | |
GOTO :MAIN | |
:DOWNLOAD | |
set URL=%~1 | |
set TITLE= | |
for /f "delims=" %%f in ('yt-dlp.exe --playlist-start 1 --playlist-end 1 --print "%%(channel)s/%%(playlist_title)s" "%URL%"') do set TITLE=%%f | |
REM CMD will barf if a string has an ampersand, so remove that. | |
set TITLE=%TITLE:&=_% | |
@REM set TITLE=%TITLE:\=_% | |
@REM set TITLE=%TITLE:<=_% | |
@REM set TITLE=%TITLE:>=_% | |
@REM set TITLE=%TITLE:?=_% | |
@REM set TITLE=%TITLE:/=_% | |
@REM set TITLE=%TITLE:"=_% | |
@REM set TITLE=%TITLE::=_% | |
@REM set TITLE=%TITLE:|=_% | |
echo. | |
echo Playlist: %ESC%[1;33m%TITLE%%ESC%[0m | |
echo. | |
yt-dlp.exe --output "%%(channel)s/%%(playlist_title)s/%%(title)s [%%(id)s].%%(ext)s" --no-simulate --print "[%%(playlist_index)d/%%(n_entries+1-)d] %%(title)s" "%URL%" | |
echo URL: %URL% | |
GOTO :EOF | |
:MAIN | |
REM del /s *.part | |
REM del /s *.ytdl | |
call :DOWNLOAD "https://www.youtube.com/channel/UC2TJVZB2ZG0HzJ1tqXpiWfw/videos" | |
call :DOWNLOAD "https://www.youtube.com/playlist?list=PL_fIcqBeKtp-eYcAkFWs5SZsyyGz9svmF" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment