Skip to content

Instantly share code, notes, and snippets.

@wincmd64
Last active January 29, 2024 07:49
Show Gist options
  • Save wincmd64/4a5463f0ba9926d38e7484b611240ccd to your computer and use it in GitHub Desktop.
Save wincmd64/4a5463f0ba9926d38e7484b611240ccd to your computer and use it in GitHub Desktop.
:: Downloads video from link in clipboard using yt-dlp and ffmpeg
:: yt-dlp.exe -- https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe
:: ffmpeg.exe -- https://github.com/GyanD/codexffmpeg/releases/download/6.1.1/ffmpeg-6.1.1-essentials_build.7z
:: https://t.me/wincmd64
@echo off
:: finds the downloads folder
FOR /F "USEBACKQ TOKENS=2,*" %%a IN (
`REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /V {374DE290-123F-4565-9164-39C4925E467B}`
) DO (SET DOWNLOADS=%%b)
:: get value from clipboard
for /f "delims=" %%i in ('powershell Get-Clipboard') do set url=%%i
:check
yt-dlp.exe -F -S vext "%url%"
if ERRORLEVEL 1 (
:: if the url is not read from the buffer - enter manually
set /p url=Enter the url:
echo.
goto check
)
echo.
set num=
set /p num=Enter videoID+audioID (for example 137+140) or leave empty for bestvideo+bestaudio:
echo.
if not defined num (
:: hit Enter for best video\audio
yt-dlp.exe -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best" "%url%" -P %DOWNLOADS% -o "%%(title).50s.%%(ext)s" --no-part
if ERRORLEVEL 1 (goto check)
) else (
yt-dlp.exe -f %num% "%url%" -P %DOWNLOADS% -o "%%(title).50s.%%(ext)s" --no-part
if ERRORLEVEL 1 (goto check)
)
color 27
explorer %DOWNLOADS%
timeout 2
@Antonij72
Copy link

Спасибо!
Только из буфера обмена у меня не читает - ругается: "Отказано в доступе". Приходится вставлять на следующем шаге.

Как пофиксить?

Windows 11 x64.

@wincmd64
Copy link
Author

wincmd64 commented Jan 29, 2024

Windows 11 x64.

подправил

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