-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutube-dlBatch.bat
485 lines (465 loc) · 14.4 KB
/
youtube-dlBatch.bat
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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
REM Copyleft Maxime Vanderwegen (Leroux47). This file is distributed under the terms of the GNU GPL license, as described here : https://en.wikipedia.org/wiki/GNU_General_Public_License.
@echo off
REM Activation de l'expansion retardee
setlocal enabledelayedexpansion
@title Youtube DlBatch
color F0
cls
echo.
echo Welcome in Youtube DL, %username% ^^!
:home
echo.
echo.
echo Main menu
echo.
echo 1. Download an audio file
echo 2. Download a video
echo 3. Modify audio format
echo 4. Modify video format
echo 5. Modify audio files download folder
echo 6. Modify video download folder
echo 7. Update Youtube-dl (a regular check is advised)
echo 8. Please, let me goooooo ^^!
echo.
set /p "choix=What do you want to do ? "
if !choix!==1 (
REM Creation du dossier d'enregistrement des fichiers audio et choix du dossier d'enregistrement des fichiers audio
if not exist %cd:~0,3%"%cd:~3,100%\variables\" (
mkdir "variables"
)
if not exist %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt" (
:audioFolderInput
echo.
set /p "audioFolder=Please enter the path of a folder where to save your audio files : "
if not exist !audioFolder! (
:optionAudio
echo.
set /p "optionAudio=This folder doesn't seem to exist... Are you sure of your choice (y/n) ? "
if !optionAudio!==y (
echo !audioFolder!> %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt"
echo.
echo The folder '!audioFolder!' has been successfully selected ^^!
if !choix!==1 (
call :choixFormatAudio
)
goto choixUrlAudio
) else if !optionAudio!==n (
REM Si l'option est non, on repose la question
echo.
echo Please enter a valid folder path...
goto audioFolderInput
) else (
REM Si l'option entree est incorrecte, on demande de corriger
echo.
echo Please select a valid option ^^!
goto optionAudio
)
) else if exist !AudioFolder! (
REM Si le dossier est présent sur le disque, on inscrit le chemin entré por l'utilisateur dans un fichier texte
REM et ensuite on le dirige vers le choix du format audio
echo !audioFolder!> %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt"
echo.
echo The folder '!audioFolder!' has been successfully selected ^^!
if !choix!==1 (
call :choixFormatAudio
)
)
) else if exist %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt" (
set /p audioFolder=< %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt"
if !choix!==1 (
call :choixFormatAudio
)
)
) else if !choix!==2 (
REM Creation du dossier d'enregistrement des videos
if not exist %cd:~0,3%"%cd:~3,100%\variables\" (
mkdir "variables"
)
if not exist %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt" (
:videoFolderInput
echo.
set /p "videoFolder=Please enter the path of a folder where to save your videos : "
if not exist !videoFolder! (
:optionVideo
echo.
set /p "optionVideo=This folder doesn't seem to exist... Are you sure of your choice (y/n) ? "
if !optionVideo!==y (
REM Si l'option est oui, on inscrit le chemin dans un fichier et on va choisir un format audio
echo !videoFolder!> %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt"
echo.
echo The folder '!videoFolder!' has been successfully selected ^^!
if !choix!==2 (
call :choixFormatVideo
)
) else if !optionVideo!==n (
REM Si l'option est non, on repose la question
echo.
echo Please enter a valid folder path...
goto videoFolderInput
) else (
REM Si l'option entree est incorrecte, on demande de corriger
echo.
echo Please enter a valid option ^^!
goto optionVideo
)
) else if exist !videoFolder! (
REM Si le dossier est présent sur le disque, on inscrit le chemin entré por l'utilisateur dans un fichier texte
REM et ensuite on le dirige vers le choix du format de la vidéo
echo !videoFolder!> %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt"
echo.
echo The folder '!videoFolder!' has been successfully selected ^^!
if !choix!==2 (
call :choixFormatVideo
)
)
) else if exist %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt" (
set /p VideoFolder=< %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt"
if !choix!==2 (
call :choixFormatVideo
)
)
) else if !choix!==3 (
echo.
set /p audioFormat=< %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
echo The current audio format is : '!audioFormat!'.
:listeFormatAudio
echo.
echo List of audio formats supported by Youtube-dl
echo.
echo 1. mp3 ^(metadata support^)
echo 2. aac
echo 3. wav
echo 4. m4a
echo 5. flac
echo.
set /p "choixFormatAudio=Please select an audio format : "
if !choixFormatAudio!==1 (
set audioFormat=mp3
echo !audioFormat!> %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
echo.
echo You've choosen the !audioFormat! format.
if !choix!==3 (
REM Fonction declenchant l'apparition d'unz question si le choix initil de l'utilisateur etait juste de modifier le chemin du dossier d'enregistrement
:choixMenuAudio
echo.
set /p "choixMenuAudio=Do you want to go back to the main menu or to download a file (m/d) ? "
if !choixMenuAudio!==m (
goto home
) else if !choixMenuAudio!==d (
if exist %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt" (
goto choixUrlAudio
) else (
call :listeFormatAudio
)
) else (
echo.
echo Please select a valid option ^^!
goto choixMenuAudio
)
exit /b
) else (
goto choixUrlAudio
)
) else if !choixFormatAudio!==2 (
set audioFormat=aac
echo !audioFormat!> %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
echo.
echo You've choosen the !audioFormat! format.
if !choix!==3 (
call :choixMenuAudio
) else (
goto choixUrlAudio
)
) else if !choixFormatAudio!==3 (
set audioFormat=wav
echo !audioFormat!> %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
echo.
echo You've choosen the !audioFormat! format.
if !choix!==3 (
call :choixMenuAudio
) else (
goto choixUrlAudio
)
) else if !choixFormatAudio!==4 (
set audioFormat=m4a
echo !audioFormat!> %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
echo.
echo You've choosen the !audioFormat! format.
if !choix!==3 (
call :choixMenuAudio
) else (
goto choixUrlAudio
)
) else if !choixFormatAudio!==5 (
set audioFormat=flac
echo !audioFormat!> %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
echo.
echo You've choosen the !audioFormat! format.
if !choix!==3 (
call :choixMenuAudio
) else (
goto choixUrlAudio
)
) else (
echo.
echo Please select a format in the list ^^!
goto listeFormatAudio
)
exit /b
) else if !choix!==4 (
echo.
set /p videoFormat= < %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo The current video format is : '!videoFormat!'.
:listeFormatVideo
echo.
echo List of video formats supported by Youtube-dl
echo.
echo 1. 3gp
echo 2. flv
echo 3. mp4
echo 4. ogg
echo 5. webm ^(no conversion needed^)
echo 6. avi
echo 7. mkv
echo.
set /p "choixFormatVideo=Please select a video format : "
if !choixFormatVideo!==1 (
set videoFormat=3gp
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
REM Idem que :choixMenuAudio
:choixMenuVideo
echo.
set /p "choixMenuVideo=Do you want to go back to the main menu or to download a file (m/d) ? "
if !choixMenuVideo!==m (
goto home
) else if !choixMenuVideo!==d (
if exist %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt" (
goto choixUrlVideo
) else (
call :listeFormatVideo
)
) else (
echo.
echo Please select a valid option ^^!
goto choixMenuVideo
)
exit /b
) else (
goto choixUrlVideo
)
) else if !choixFormatVideo!==2 (
set videoFormat=flv
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
call :choixMenuVideo
) else (
goto choixUrlVideo
)
) else if !choixFormatVideo!==3 (
set videoFormat=mp4
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
call :choixMenuVideo
) else (
goto choixUrlVideo
)
) else if !choixFormatVideo!==4 (
set videoFormat=ogg
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
call :choixMenuVideo
) else (
goto choixUrlVideo
)
) else if !choixFormatVideo!==5 (
set videoFormat=webm
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
call :choixMenuVideo
) else (
goto choixUrlVideo
)
) else if !choixFormatVideo!==6 (
set videoFormat=avi
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
call :choixMenuVideo
) else (
goto choixUrlVideo
)
) else if !choixFormatVideo!==7 (
set videoFormat=mkv
echo !videoFormat!> %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
echo.
echo You've choosen the !videoFormat! format.
if !choix!==4 (
call :choixMenuVideo
) else (
goto choixUrlVideo
)
) else (
echo.
echo Please select a format in the list ^^!
goto listeFormatVideo
)
goto home
exit /b
) else if !choix!==5 (
if not exist %cd:~0,3%"%cd:~3,100%\variables\" (
mkdir "variables"
)
if exist %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt" (
set /p audioFolder= < %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt"
echo.
echo Audio files are currently saved in the '!audioFolder!' folder.
)
:changeAudioFolder
echo.
set /p "audioFolder=Please enter the path of a folder where to save your audio files : "
if not exist !audioFolder! (
:optionAudio
echo.
set /p "optionAudio=This folder doesn't seem to exist... Are you sure of your choice (y/n) ? "
if !optionAudio!==y (
echo !audioFolder!> %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt"
echo.
echo The '!audioFolder!' folder has been successfully selected ^^!
goto choixUrlAudio
) else if !optionAudio!==n (
echo.
echo Please enter a valid folder path...
goto changeAudioFolder
) else (
echo.
echo Please select a valid option ^^!
goto optionAudio
)
) else if exist !audioFolder! (
echo.
echo !audioFolder!> %cd:~0,3%"%cd:~3,100%\variables\audioFolder.txt"
echo The '!audioFolder!' folder has been successfully selected ^^!
call :choixMenuAudio
)
) else if !choix!==6 (
if not exist %cd:~0,3%"%cd:~3,100%\variables\" (
mkdir "variables"
)
if exist %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt" (
set /p videoFolder=< %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt"
echo.
echo Video files are currently saved in the '!videoFolder!' folder.
)
:changeVideoFolder
echo.
set /p "videoFolder=Please enter the path of a folder where to save your video files : "
if not exist !videoFolder! (
:optionVideo
echo.
set /p "optionVideo=This folder doesn't seem to exist... Are you sure of your choice (y/n) ? "
if !optionVideo!==y (
echo !videoFolder!> %cd:~0,3%"%cd:~3,100%\variables\videoFolder.txt"
echo.
echo The '!videoFolder!' folder has been successfully selected ^^!
goto choixUrlvideo
) else if !optionVideo!==n (
echo.
echo Please enter a valid folder path...
goto changeVideoFolder
) else (
echo.
echo Please select a valid option ^^!
goto optionVideo
)
)
call :choixMenuVideo
) else if !choix!==7 (
echo.
echo Updating Youtube-dl...
start /b /wait youtube-dl -U
timeout /t 1 /nobreak > nul
goto home
) else if !choix!==8 (
echo.
echo See you soon, %username% ^^!
timeout /t 1 /nobreak > nul
exit
) else (
echo.
echo Please select a valid option ^^!
goto home
)
:choixFormatAudio
REM Si le format video a ete enregistre dans le fichier audioFormat, c'est qu'il existe et donc le format est lu par le script pour definir le format de sortie du fichier audio
REM Sinon, on appelle la liste des formats audio
if not exist %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt" (
echo.
call :listeFormatAudio
) else (
set /p audioFormat=< %cd:~0,3%"%cd:~3,100%\variables\audioFormat.txt"
)
goto choixUrlAudio
exit /b
:choixUrlAudio
REM On demande a l'utilisateur d'entrer l'url d'un fichier audio
echo.
set /p "urlAudio=Please enter the URL of an audio file to download : "
goto audioProcessing
:audioProcessing
echo.
REM Si le format audio est "mp3", on ajoute des metadonnes, sinon non (formats non supportes)
if !audioFormat!==mp3 (
start /b /wait %cd:~0,3%"%cd:~3,100%\youtube-dl.exe" -x --audio-format !audioFormat! -o "!audioFolder!\%%(title)s.%%(ext)s" !urlAudio! --youtube-skip-dash-manifest --embed-thumbnail --add-metadata
) else (
echo !audioFormat!
start /b /wait %cd:~0,3%"%cd:~3,100%\youtube-dl.exe" -x --audio-format !audioFormat! -o "!audioFolder!\%%(title)s.%%(ext)s" !urlAudio! --youtube-skip-dash-manifest --embed-thumbnail
)
echo.
timeout /t 2 /nobreak > nul
echo Audio file successfully downloaded ^^!
goto end
:choixFormatVideo
REM Si le format video a ete enregistre dans le fichier videoFormat, c'est qu'il existe et donc le format est lu par le script pour definir le format de sortie de la video
REM Sinon on appelle la liste des formats video
if not exist %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt" (
echo.
call :listeFormatVideo
) else (
set /p videoFormat=< %cd:~0,3%"%cd:~3,100%\variables\videoFormat.txt"
)
goto choixUrlVideo
exit /b
:choixUrlVideo
REM On demande a l'utilisateur d'entrer l'url d'une video
echo.
set /p "urlVideo=Please enter the URL of a video file to download : "
goto videoProcessing
:videoProcessing
echo.
REM Si le format video est "webm", on telecharge simplement la video, sinon on demande sa conversion apres le telechargement
if !videoFormat!==webm (
start /b /wait youtube-dl -o "!videoFolder!\%%(title)s.%%(ext)s" !urlVideo! --youtube-skip-dash-manifest --add-metadata
) else (
start /b /wait youtube-dl --recode-video !videoFormat! -o "!videoFolder!\%%(title)s.%%(ext)s" !urlVideo! --youtube-skip-dash-manifest --add-metadata
)
echo.
timeout /t 2 /nobreak > nul
echo.
echo Video file successfully downloaded ^^!
goto end
:end
goto home
REM Arret de l'expansion retardee
endlocal