====== Youtube DL (yt-dlp) ======
A pendre ici pour windows avec ffmpeg et à unzip dans C:\ : {{ :0:yt-dlp.7z |}}
Toutes les infos ici : [[https://github.com/yt-dlp/yt-dlp]]
Lancer un terminal cmd :
cd "C:\yt-dlp"
yt-dlp -U
# Une playlist en mp3
yt-dlp -x --audio-format mp3 --audio-quality 0 -o "%(album_artist)s/%(title)s.%(ext)s" "https://www.youtube.com/watch?list=AAAAAAA" --ffmpeg-location "C:\yt-dlp\ffmpeg-5.0-essentials_build\bin\ffmpeg.exe"
Pour ajouter le numéro de piste on peut ajouter :
%(playlist_index)s.
# Une chaine avec des vidéos
yt-dlp -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" "https://www.youtube.com/playlist?list=PLq9_U6QEXNyf0uc4hjxss51gv9c-b5vhN"
# Ignorer les erreurs
-i
# Reprendre les DL interrompus
-c
#astuce #YouTube #yt-dlp
Parfois j'archive des vidéos YouTube. Il arrive qu'elles soient en anglais, mais heureusement avec yt-dlp on peut récupérer un beau mkv avec les sous-titres intégrés :
yt-dlp --write-auto-sub --embed-subs --merge-output-format mkv
ou
yt-dlp --write-auto-sub --embed-subs --sub-lang "en.*" --merge-output-format mkv
(retirez --write-auto-sub si vous ne voulez pas des sous-titres auto-généré par YouTube)
To select the video quality, first use the -F option to list the available formats, here’s an example:
youtube-dl -F 'http://www.youtube.com/watch?v=P9pzm5b6FFY'
Here’s the output:
[youtube] Setting language
[youtube] P9pzm5b6FFY: Downloading webpage
[youtube] P9pzm5b6FFY: Downloading video info webpage
[youtube] P9pzm5b6FFY: Extracting video information
[info] Available formats for P9pzm5b6FFY:
format code extension resolution note
140 m4a audio only DASH audio , audio@128k (worst)
160 mp4 144p DASH video , video only
133 mp4 240p DASH video , video only
134 mp4 360p DASH video , video only
135 mp4 480p DASH video , video only
136 mp4 720p DASH video , video only
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
The best quality is 22 so use -f 22 instead of -F to download the MP4 video with 1280x720 resolution like this:
youtube-dl -f 22 'http://www.youtube.com/watch?v=P9pzm5b6FFY'
Youtube has separated the video and audio streams for the lines labeled DASH so we also need to pick the highest quality audio
which in this case is the line starting with 141.
Then we run youtube-dl again this time specifying the audio and video:
youtube-dl -f 137+141 https://www.youtube.com/watch\?v\=-pxRXP3w-sQ
Output template examples
Note that on Windows you may need to use double quotes instead of single.
$ yt-dlp --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc
yt-dlp test video ''_ä↭𝕐.mp4
# All kinds of weird characters
$ yt-dlp --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc --restrict-filenames
yt-dlp_test_video_.mp4
# A simple file name
# Download YouTube playlist videos in separate directory indexed by video order in a playlist
$ yt-dlp -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re
# Download all playlists of YouTube channel/user keeping each playlist in separate directory:
$ yt-dlp -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists
# Download Udemy course keeping each chapter in separate directory under MyVideos directory in your home
$ yt-dlp -u user -p password -o '~/MyVideos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/java-tutorial/
# Download entire series season keeping each series and each season in separate directory under C:/MyVideos
$ yt-dlp -o "C:/MyVideos/%(series)s/%(season_number)s - %(season)s/%(episode_number)s - %(episode)s.%(ext)s" https://videomore.ru/kino_v_detalayah/5_sezon/367617
# Stream the video being downloaded to stdout
$ yt-dlp -o - BaW_jenozKc