Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal enabledelayedexpansion
- REM Define the yt-dlp executable name
- set "yt_dlp_exe=yt-dlp.exe"
- :start
- cd /d %~dp0
- echo Available commands:
- echo 0. -F (List available formats)
- echo 1. ^<=1080p (MP4)
- echo 2. ^<=1080p (MP4 without archive)
- echo 3. bestvideo (MP4 without archive)
- echo 4. with cookies (mp4)
- echo --
- echo 5. audio (MP3)
- echo 6. audio (MP3 without archive)
- echo 7. with cookies (mp3)
- echo --
- echo 8. from list_video.txt (mp4)
- echo 9. from list_audio.txt (mp3)
- echo.
- set /p choice=Enter the command number or custom command:
- REM Check if the user has entered a predefined choice
- if "%choice%"=="0" (
- set "commands=-F --cookies youtube.txt"
- set "output_template="
- ) else if "%choice%"=="1" (
- set "commands=-f bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4][height<=1080]/bv*[height<=1080]+ba/best --download-archive archive-video.txt -N 4"
- set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
- ) else if "%choice%"=="2" (
- set "commands=-f bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4][height<=1080]/bv*[height<=1080]+ba/best -N 4"
- set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
- ) else if "%choice%"=="3" (
- set "commands=-f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best -N 6"
- set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
- ) else if "%choice%"=="4" (
- set "commands=-f bestvideo[ext=mp4]/bestaudio/0 --download-archive archive-video.txt -N 4 --cookies youtube.txt"
- set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
- ) else if "%choice%"=="5" (
- set "commands=-f bestaudio[ext=mp3]/bestaudio/0 --extract-audio --audio-format mp3 --audio-quality 0 --download-archive archive-audio.txt -N 4"
- set "output_template=download/%%(title)s-%%(id)s.%%(ext)s"
- ) else if "%choice%"=="6" (
- set "commands=-f bestaudio[ext=mp3]/bestaudio/0 --extract-audio --audio-format mp3 --audio-quality 0 -N 4"
- set "output_template=download/%%(title)s-%%(id)s.%%(ext)s"
- ) else if "%choice%"=="7" (
- set "commands=-f bestaudio[ext=mp3]/bestaudio/0 --extract-audio --audio-format mp3 --audio-quality 0 --download-archive archive-audio.txt --cookies yandex.txt -N 4"
- set "output_template=download/%%(title)s-%%(id)s.%%(ext)s"
- ) else if "%choice%"=="8" (
- set "commands=-f bestvideo[height^<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4][height^<=1080]/bv*[height^<=1080]+ba/best -N 6 --download-archive archive-video.txt -a list_video.txt"
- set "output_template=download/video/%%(uploader,channel)s/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
- set "skip_url_prompt=1"
- ) else if "%choice%"=="9" (
- set "commands=-f bestaudio[ext=mp3]/bestaudio/0 --extract-audio --audio-format mp3 --audio-quality 0 --download-archive archive-audio.txt -a list_audio.txt -N 4 --cookies yandex.txt"
- set "output_template=download/audio/%%(uploader,channel)s/%%(title)s [%%(id)s].%%(ext)s"
- set "skip_url_prompt=1"
- ) else (
- REM Custom command
- set "commands=%choice%"
- )
- if defined skip_url_prompt (
- set "url="
- ) else (
- set /p url=Enter the URL:
- REM Check if the URL was provided
- if not defined url (
- echo No URL provided. Returning to start...
- pause >nul
- goto start
- )
- )
- set "skip_url_prompt=" REM Сбрасываем значение после использования
- REM Attempt to execute the command, and handle errors
- if "%choice%"=="0" (
- %yt_dlp_exe% !commands! !url!
- ) else if defined output_template (
- if defined url (
- %yt_dlp_exe% !commands! -o "!output_template!" !url!
- ) else (
- %yt_dlp_exe% !commands! -o "!output_template!"
- )
- ) else (
- if defined url (
- %yt_dlp_exe% !commands! !url!
- ) else (
- %yt_dlp_exe% !commands!
- )
- )
- if %errorlevel% neq 0 (
- echo.
- echo Command failed with error level %errorlevel%. Please check the error message above.
- echo.
- ) else (
- echo.
- echo Download completed successfully.
- echo.
- )
- echo Press any key to continue...
- pause >nul
- goto start
Advertisement
Add Comment
Please, Sign In to add comment