Skip to content

Instantly share code, notes, and snippets.

@seamonkey420
Last active March 14, 2022 03:43
Show Gist options
  • Save seamonkey420/03bddc91c840d9dcd7c3c160d758fd10 to your computer and use it in GitHub Desktop.
Save seamonkey420/03bddc91c840d9dcd7c3c160d758fd10 to your computer and use it in GitHub Desktop.
Easy batch file to just download a single youtube video or playlist via YT-DLP. Update variables to where yt-dlp is saved and where you want videos saved to.
:: -------------------------------------------------------------
:: Quick way to download youtube vids via yt-dlp
:: Set yt-dlpLOC to where yt-dlp.exe resides
:: yt-dlp set to embed thumbnails and metadata
:: set to force US geolocation and use best quality options
:: outputs video files as mp4
:: Opens up folder where videos are saevd to once completed
:: Seamonkey420 3/10/2022
:: --------------------------------------------------------------
@echo off
::Variables, Update to match your system
set yt-dlpLOC=C:\Users\username\Downloads\YT
set SaveToLocation=C:\Users\username\Downloads\YT\Downloads
:Main
set /p url="Paste URL for Youtube Video or Playlist to Download: "
"%yt-dlpLOC%\yt-dlp.exe" -f b --geo-bypass-country US --embed-thumbnail --add-metadata --compat-options embed-metadata -P "%SaveToLocation%" "%url%"
explorer.exe "%SaveToLocation%"
pause
@seamonkey420
Copy link
Author

note, i need to detect when & is in the url (ie playlists) since it is an escapable character and requires a ^ in front of (ie youtube.com/url&playlist needs to be youtube.com/url^&playlist)

plan to update with basic logic later

@seamonkey420
Copy link
Author

nevermind, just need to use " " around variable to avoid escapable characters issues, all fixed.

@seamonkey420
Copy link
Author

seamonkey420 commented Mar 14, 2022

To add to right-click / context window on the desktop, create a cmd of the code and then update registry keys to the following:

yt-dlp context menu example

just update paths to where the yt-dlp.exe is located (to show proper icon in context menu) and where above .cmd file is. example below of registry keys needed.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open YouTube-DLP]
"icon"="\"C:\\Users\\username\\Scripts\\YouTube DL\\yt-dlp.exe\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Open YouTube-DLP\command]
@="cmd.exe /k \"C:\\Users\\username\\Scripts\\YouTube DL\\DownloadRightClick.cmd\""

icon

command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment