ozhegovvv

yt-dlp

Sep 1st, 2024 (edited)
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. REM Define the yt-dlp executable name
  5. set "yt_dlp_exe=yt-dlp.exe"
  6.  
  7. :start
  8. cd /d %~dp0
  9.  
  10. echo Available commands:
  11. echo 0. -F (List available formats)
  12. echo 1. ^<=1080p (MP4)
  13. echo 2. ^<=1080p (MP4 without archive)
  14. echo 3. bestvideo (MP4 without archive)
  15. echo 4. with cookies (mp4)
  16. echo --
  17. echo 5. audio (MP3)
  18. echo 6. audio (MP3 without archive)
  19. echo 7. with cookies (mp3)
  20. echo --
  21. echo 8. from list_video.txt (mp4)
  22. echo 9. from list_audio.txt (mp3)
  23. echo.
  24.  
  25. set /p choice=Enter the command number or custom command:
  26.  
  27. REM Check if the user has entered a predefined choice
  28. if "%choice%"=="0" (
  29. set "commands=-F --cookies youtube.txt"
  30. set "output_template="
  31. ) else if "%choice%"=="1" (
  32. 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"
  33. set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
  34. ) else if "%choice%"=="2" (
  35. set "commands=-f bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4][height<=1080]/bv*[height<=1080]+ba/best -N 4"
  36. set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
  37. ) else if "%choice%"=="3" (
  38. set "commands=-f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best -N 6"
  39. set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
  40. ) else if "%choice%"=="4" (
  41. set "commands=-f bestvideo[ext=mp4]/bestaudio/0 --download-archive archive-video.txt -N 4 --cookies youtube.txt"
  42. set "output_template=download/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
  43. ) else if "%choice%"=="5" (
  44. set "commands=-f bestaudio[ext=mp3]/bestaudio/0 --extract-audio --audio-format mp3 --audio-quality 0 --download-archive archive-audio.txt -N 4"
  45. set "output_template=download/%%(title)s-%%(id)s.%%(ext)s"
  46. ) else if "%choice%"=="6" (
  47. set "commands=-f bestaudio[ext=mp3]/bestaudio/0 --extract-audio --audio-format mp3 --audio-quality 0 -N 4"
  48. set "output_template=download/%%(title)s-%%(id)s.%%(ext)s"
  49. ) else if "%choice%"=="7" (
  50. 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"
  51. set "output_template=download/%%(title)s-%%(id)s.%%(ext)s"
  52. ) else if "%choice%"=="8" (
  53. 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"
  54. set "output_template=download/video/%%(uploader,channel)s/%%(title)s[%%(height)sp][%%(id)s].%%(ext)s"
  55. set "skip_url_prompt=1"
  56. ) else if "%choice%"=="9" (
  57. 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"
  58. set "output_template=download/audio/%%(uploader,channel)s/%%(title)s [%%(id)s].%%(ext)s"
  59. set "skip_url_prompt=1"
  60. ) else (
  61. REM Custom command
  62. set "commands=%choice%"
  63. )
  64.  
  65.  
  66. if defined skip_url_prompt (
  67. set "url="
  68. ) else (
  69. set /p url=Enter the URL:
  70.  
  71. REM Check if the URL was provided
  72. if not defined url (
  73. echo No URL provided. Returning to start...
  74. pause >nul
  75. goto start
  76. )
  77. )
  78.  
  79. set "skip_url_prompt=" REM Сбрасываем значение после использования
  80.  
  81. REM Attempt to execute the command, and handle errors
  82. if "%choice%"=="0" (
  83. %yt_dlp_exe% !commands! !url!
  84. ) else if defined output_template (
  85. if defined url (
  86. %yt_dlp_exe% !commands! -o "!output_template!" !url!
  87. ) else (
  88. %yt_dlp_exe% !commands! -o "!output_template!"
  89. )
  90. ) else (
  91. if defined url (
  92. %yt_dlp_exe% !commands! !url!
  93. ) else (
  94. %yt_dlp_exe% !commands!
  95. )
  96. )
  97.  
  98. if %errorlevel% neq 0 (
  99. echo.
  100. echo Command failed with error level %errorlevel%. Please check the error message above.
  101. echo.
  102. ) else (
  103. echo.
  104. echo Download completed successfully.
  105. echo.
  106. )
  107.  
  108. echo Press any key to continue...
  109. pause >nul
  110.  
  111. goto start
Tags: youtube yt-dlp
Advertisement
Add Comment
Please, Sign In to add comment