-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYouTube Video Downloader.bat
More file actions
459 lines (385 loc) · 13.2 KB
/
Copy pathYouTube Video Downloader.bat
File metadata and controls
459 lines (385 loc) · 13.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
@echo off
chcp 65001 >nul
setlocal EnableDelayedExpansion
title YouTube Video Downloader v4.5 - Munna MasterMind
REM ================= CONFIG =================
set ROOT=%~dp0
set YTDLP=%ROOT%yt-dlp.exe
set FFMPEG=%ROOT%ffmpeg.exe
set OUTDIR=%ROOT%Downloads
set TMPFILE=%TEMP%\ytformats.txt
set USER_AGENT=
set EXTRA_OPTS=
if not exist "%OUTDIR%" mkdir "%OUTDIR%"
REM ================= MENU ===================
:MENU
cls
echo.
echo ╔══════════════════════════════════════════════╗
echo ║ YouTube Downloader - Munna MasterMind ║
echo ╠══════════════════════════════════════════════╣
echo ║ 1. Complete Dependency Setup ║
echo ║ 2. Download Single Videos ║
echo ║ 3. Download Playlist Videos ║
echo ║ 4. Download Bulk Videos at Once ║
echo ║ 5. Contact Us For Development ║
echo ║ 0. Exit Program ║
echo ╚══════════════════════════════════════════════╝
echo.
choice /c 012345 /n /m "Select Option Between [0-5]: "
if errorlevel 6 goto CONTACT
if errorlevel 5 goto BULK_VIDEOS
if errorlevel 4 goto PLAYLIST_VIDEO
if errorlevel 3 goto SINGLE_VIDEO
if errorlevel 2 goto INSTALL_TOOLS
if errorlevel 1 exit /b
goto MENU
REM ============ INSTALL TOOLS ===============
:INSTALL_TOOLS
cls
echo.
echo Downloading yt-dlp for Dependency Setup...
echo.
powershell -Command "Invoke-WebRequest https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe -OutFile '%YTDLP%'"
echo [OK] yt-dlp.exe successfully downloaded and ready to use!
echo.
REM --- Method 1: curl ---
echo Downloading FFmpeg for Video Encoding...
echo.
where curl >nul 2>&1
if not errorlevel 1 (
curl -L -o ffmpeg.zip "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"
if exist "ffmpeg.zip" goto EXTRACT_NOW
)
REM --- Method 2: bitsadmin ---
bitsadmin /transfer "FFmpegDL" /download /priority normal ^
"https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip" "ffmpeg.zip"
if exist "ffmpeg.zip" goto EXTRACT_NOW
REM --- Method 3: PowerShell ---
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip' -OutFile 'ffmpeg.zip'}"
if not exist "ffmpeg.zip" (
echo [ERROR] FFmpeg download failed!
echo Please check your internet connection and try again or download manually from: https://github.com/BtbN/FFmpeg-Builds/releases/latest
pause
goto MENU
)
:EXTRACT_NOW
echo.
echo Extracting FFmpeg for Video Encoding...
powershell -Command "Expand-Archive 'ffmpeg.zip' 'ffmpeg_temp' -Force"
for /r "ffmpeg_temp" %%F in (ffmpeg.exe) do (
copy /y "%%F" "%ROOT%ffmpeg.exe" >nul
)
rd /s /q "ffmpeg_temp"
del ffmpeg.zip
echo.
echo [OK] ffmpeg.exe successfully downloaded and ready to use!
echo.
pause
goto MENU
REM ============ CHECK yt-dlp ================
:CHECK_YTDLP
if not exist "%YTDLP%" (
echo.
echo yt-dlp.exe not found!
echo Please run option 1 first for Dependency Setup.
echo.
pause
goto MENU
)
exit /b
REM ============ CHECK FFmpeg ================
:CHECK_FFMPEG
if not exist "%FFMPEG%" (
echo.
echo ffmpeg.exe not found!
echo Please run option 1 first for Dependency Setup.
echo.
pause
goto MENU
)
exit /b
REM ============ SINGLE VIDEO ================
:SINGLE_VIDEO
call :CHECK_YTDLP
call :CHECK_FFMPEG
set PLAYLIST_FLAG=--no-playlist
set OUTPUT_TEMPLATE=%OUTDIR%\%%(title)s.%%(ext)s
:SINGLE_LOOP
call :DOWNLOAD_FLOW
set /p AGAIN=Do you want to download more videos? (y/n):
if /I "%AGAIN%"=="y" goto SINGLE_LOOP
if /I "%AGAIN%"=="n" goto MENU
goto SINGLE_LOOP
:DOWNLOAD_FLOW
cls
echo.
echo ╔═══════════════════════════════════════════════════╗
echo ║ YouTube Video Downloader by - Munna MasterMind ║
echo ║ https://munna-soft.github.io/Portfolio ║
echo ║ https://facebook.com/The.Munna ║
echo ╚═══════════════════════════════════════════════════╝
echo.
set "VIDEO_URL="
set /p VIDEO_URL=Input YouTube Video URLs:
if "%VIDEO_URL%"=="" goto MENU
echo.
echo Fetching available formats...
echo.
"%YTDLP%" -F %PLAYLIST_FLAG% "%VIDEO_URL%" > "%TMPFILE%"
echo.
echo ========== Available Formats (MP3 / MP4) ==========
set COUNT=0
for /f "tokens=*" %%A in ('type "%TMPFILE%" ^| findstr /i "mp4 mkv mp3" ^| findstr /v /i "m3u8"') do (
set /a COUNT+=1
echo !COUNT!^) %%A
set "FMT_!COUNT!=%%A"
)
if !COUNT!==0 (
echo.
echo [ERROR] No supported formats found! Please check the URL.
echo.
del "%TMPFILE%" 2>nul
exit /b
)
echo --------------------------------------------------
echo.
echo Tips: For best quality, choose the highest number (usually at the bottom)
echo.
set /p SERIAL=Input Format/Resolution Serial Number:
for /f "tokens=1" %%B in ("!FMT_%SERIAL%!") do set FORMAT_CODE=%%B
echo.
echo Downloading Video...
echo !FMT_%SERIAL%! | findstr /i "audio" >nul
if errorlevel 1 (
"%YTDLP%" -f %FORMAT_CODE%+bestaudio --merge-output-format mp4 ^
-o "%OUTPUT_TEMPLATE%" %EXTRA_OPTS% %PLAYLIST_FLAG% "%VIDEO_URL%"
) else (
"%YTDLP%" -f %FORMAT_CODE% ^
-o "%OUTPUT_TEMPLATE%" %EXTRA_OPTS% %PLAYLIST_FLAG% "%VIDEO_URL%"
)
REM ============ THUMBNAILS DOWNLOAD ==============
echo.
echo Downloading thumbnails for video...
"%YTDLP%" --skip-download --write-thumbnail --convert-thumbnails jpg ^
-o "%OUTPUT_TEMPLATE%" %PLAYLIST_FLAG% "%VIDEO_URL%"
del "%TMPFILE%" 2>nul
echo.
echo ✅ Download Completed!
exit /b
REM ============ PLAYLIST VIDEO ==============
:PLAYLIST_VIDEO
call :CHECK_YTDLP
call :CHECK_FFMPEG
set PLAYLIST_FLAG=
set OUTPUT_TEMPLATE=%OUTDIR%\%%(playlist_title)s\%%(title)s.%%(ext)s
cls
echo.
echo ╔═══════════════════════════════════════════════════╗
echo ║ YouTube Video Downloader by - Munna MasterMind ║
echo ║ https://munna-soft.github.io/Portfolio ║
echo ║ https://facebook.com/The.Munna ║
echo ╚═══════════════════════════════════════════════════╝
echo.
set "PLAYLIST_URL="
set /p PLAYLIST_URL=Input YouTube Playlist URLs:
if "%PLAYLIST_URL%"=="" goto MENU
echo.
echo Fetching available formats from first video in playlist...
echo.
"%YTDLP%" --playlist-items 1 -F %PLAYLIST_FLAG% "%PLAYLIST_URL%" > "%TMPFILE%"
echo.
echo ========== Available Formats (MP3 / MP4) ==========
set COUNT=0
for /f "tokens=*" %%A in ('type "%TMPFILE%" ^| findstr /i "mp4 mkv mp3" ^| findstr /v /i "m3u8"') do (
set /a COUNT+=1
echo !COUNT!^) %%A
set "FMT_!COUNT!=%%A"
)
if !COUNT!==0 (
echo.
echo [ERROR] No supported formats found! Please check the URL.
echo.
del "%TMPFILE%" 2>nul
pause
goto MENU
)
echo --------------------------------------------------
echo.
echo Tips: For best quality, choose the highest number (usually at the bottom)
echo.
set /p SERIAL=Select Format/Resolution Serial Number for all playlist videos:
for /f "tokens=1" %%B in ("!FMT_%SERIAL%!") do set FORMAT_CODE=%%B
echo.
echo Starting playlist download...
echo !FMT_%SERIAL%! | findstr /i "audio" >nul
if errorlevel 1 (
"%YTDLP%" -f %FORMAT_CODE%+bestaudio --merge-output-format mp4 ^
-o "%OUTPUT_TEMPLATE%" %EXTRA_OPTS% %PLAYLIST_FLAG% "%PLAYLIST_URL%"
) else (
"%YTDLP%" -f %FORMAT_CODE% ^
-o "%OUTPUT_TEMPLATE%" %EXTRA_OPTS% %PLAYLIST_FLAG% "%PLAYLIST_URL%"
)
REM ============ THUMBNAILS DOWNLOAD =============
echo.
echo Downloading thumbnails for playlist videos...
"%YTDLP%" --skip-download --write-thumbnail --convert-thumbnails jpg ^
-o "%OUTPUT_TEMPLATE%" %PLAYLIST_FLAG% "%PLAYLIST_URL%"
del "%TMPFILE%" 2>nul
echo.
echo ✅ Playlist download completed!
pause
goto MENU
REM ============ BULK VIDEOS ==============
:BULK_VIDEOS
call :CHECK_YTDLP
call :CHECK_FFMPEG
set PLAYLIST_FLAG=--no-playlist
set OUTPUT_TEMPLATE=%OUTDIR%\%%(title)s.%%(ext)s
:BULK_START
cls
echo.
echo ╔═══════════════════════════════════════════════════╗
echo ║ YouTube Video Downloader by - Munna MasterMind ║
echo ║ https://munna-soft.github.io/Portfolio ║
echo ║ https://facebook.com/The.Munna ║
echo ╚═══════════════════════════════════════════════════╝
echo.
set /p "VIDEO_COUNT=How many videos do you want to download? (1-100): "
echo.
if "%VIDEO_COUNT%"=="" goto MENU
echo %VIDEO_COUNT%| findstr /r "^[1-9][0-9]*$" >nul
if errorlevel 1 (
echo Invalid input! Please enter a number between 1-100.
pause
goto BULK_START
)
set /a NUM=VIDEO_COUNT 2>nul
if %NUM% LSS 1 (
echo Minimum 1 video required!
pause
goto BULK_START
)
if %NUM% GTR 100 (
echo Maximum 100 videos allowed!
pause
goto BULK_START
)
set "URL_LIST="
set /a CURRENT=1
:GET_URLS
if %CURRENT% GTR %VIDEO_COUNT% goto GOT_URLS
echo [Video %CURRENT% of %VIDEO_COUNT%]
set "URL="
set /p "URL=Enter YouTube URLs: "
if "!URL!"=="" (
echo URL cannot be empty! Please try again.
echo.
goto GET_URLS
)
set "URL_LIST=!URL_LIST!,"!URL!""
echo.
set /a CURRENT+=1
goto GET_URLS
:GOT_URLS
if "!URL_LIST!"=="" (
echo No URLs entered!
pause
goto MENU
)
set "URL_LIST=!URL_LIST:~1!"
for /f "tokens=1 delims=," %%A in ("!URL_LIST!") do (
set "FIRST_URL=%%~A"
set "FIRST_URL=!FIRST_URL:"=!"
)
if "!FIRST_URL!"=="" (
echo Could not process URLs!
pause
goto MENU
)
echo.
echo Fetching available formats from first video...
echo.
"%YTDLP%" -F %PLAYLIST_FLAG% "!FIRST_URL!" > "%TMPFILE%"
echo.
echo ========== Available Formats (MP3 / MP4) ==========
set COUNT=0
for /f "tokens=*" %%A in ('type "%TMPFILE%" ^| findstr /i "mp4 mkv mp3" ^| findstr /v /i "m3u8"') do (
set /a COUNT+=1
echo !COUNT!^) %%A
set "FMT_!COUNT!=%%A"
)
if !COUNT!==0 (
echo.
echo No supported formats found! Please check the URLs.
echo.
pause
goto MENU
)
:SELECT_FORMAT
echo --------------------------------------------------
echo.
echo Tips: For best quality, choose the highest number (usually at the bottom)
echo.
set /p "SERIAL=Select Format/Resolution Serial Number for all videos: "
if "!FMT_%SERIAL%!"=="" (
echo Invalid selection! Please choose a number from the list.
goto SELECT_FORMAT
)
for /f "tokens=1" %%B in ("!FMT_%SERIAL%!") do set FORMAT_CODE=%%B
echo.
echo Starting download of %VIDEO_COUNT% videos...
set /a DOWNLOADED=0
set /a TOTAL=%VIDEO_COUNT%
set "TEMP_LIST=!URL_LIST!"
:DOWNLOAD_LOOP
if "!TEMP_LIST!"=="" goto DOWNLOAD_DONE
for /f "tokens=1* delims=," %%A in ("!TEMP_LIST!") do (
set "CURRENT_URL=%%~A"
set "TEMP_LIST=%%B"
)
set "CURRENT_URL=!CURRENT_URL:"=!"
echo.
echo ============================================
set /a DOWNLOADED+=1
echo [Downloading video !DOWNLOADED! of !TOTAL!]
echo ============================================
echo !FMT_%SERIAL%! | findstr /i "audio" >nul
if errorlevel 1 (
"%YTDLP%" -f %FORMAT_CODE%+bestaudio --merge-output-format mp4 ^
-o "%OUTPUT_TEMPLATE%" %EXTRA_OPTS% %PLAYLIST_FLAG% "!CURRENT_URL!"
) else (
"%YTDLP%" -f %FORMAT_CODE% ^
-o "%OUTPUT_TEMPLATE%" %EXTRA_OPTS% %PLAYLIST_FLAG% "!CURRENT_URL!"
)
REM ============= THUMBNAILS DOWNLOAD ==============
echo.
echo Downloading thumbnail for current video...
"%YTDLP%" --skip-download --write-thumbnail --convert-thumbnails jpg ^
-o "%OUTPUT_TEMPLATE%" %PLAYLIST_FLAG% "!CURRENT_URL!"
goto DOWNLOAD_LOOP
:DOWNLOAD_DONE
del "%TMPFILE%" 2>nul
echo.
echo ╔═══════════════════════════════════════════════════╗
echo ║✅ All %VIDEO_COUNT% videos downloaded successfully!║
echo ╚═══════════════════════════════════════════════════╝
echo.
pause
goto MENU
REM ============ CONTACT INFO ================
:CONTACT
cls
color 0A
echo.
echo: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo: :: YouTube Video Downloader Premium Edition ::
echo: :: Author : Munna MasterMind ::
echo: :: https://github.com/Munna-Soft ::
echo: :: https://facebook.com/The.Munna ::
echo: :: Location : Dhaka, Bangladesh ::
echo: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo.
pause
goto MENU
REM ================= CODE BY Munna MasterMind =================