-
youtube-dl
doc officielle : https://github.com/ytdl-org/youtube-dl/blob/master/README.md
INSTALLATION
UBUNTU
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
youtube-dl -U
Si message d’erreur
/usr/bin/env: «python»: Aucun fichier ou dossier de ce type, fairesudo apt install pythonSi ça ne marche pas, recommencer en remplaçant
/usr/local/binpar/usr/binusage :
youtube-dl [options] URL youtube-dl -t http://vimeo.com/69722654
WINDOWS
1 - Télécharger Python ici (version 2 ou 3). Avec la version 3, tout marche nickel.
2 - Télécharger youtube-dl ici
3 - Installer Python
4 - Déplacer youtube-dl.exe à la racine de c: (par exemple)
5 - Exécuter l’interpréteur de commandes : [WIN]+[R] > taper cmd
6 - taper
cd /(au cas où le fichier youtube-dl.exe se trouve à la racine de c:)7 - puis taper
youtube-dl.exe lien_de_la_video8 - La vidéo se télécharge
youtube-dl.exe [options] URL youtube-dl.exe -t http://vimeo.com/69722654
MISES A JOUR
LINUX
sudo pip install --upgrade youtube_dl
Si plusieurs versions de Python présentes :
sudo python3.5 -m pip install --upgrade youtube_dl
OPTIONS
-trenommer le fichier téléchargé avec le titre-Fconnaître les formats disponibles d’une vidéo-f xxtélécharger avec le format spécifiquexxNOM DU FICHIER DE SORTIE
-opermet d’indiquer le schéma de sortie :%(NAME)sor%(NAME)05did(string): Video identifiertitle(string): Video titleurl(string): Video URLext(string): Video filename extensionalt_title(string): A secondary title of the videodisplay_id(string): An alternative identifier for the videouploader(string): Full name of the video uploaderlicense(string): License name the video is licensed undercreator(string): The creator of the videorelease_date(string): The date (YYYYMMDD) when the video was releasedtimestamp(numeric): UNIX timestamp of the moment the video became availableupload_date(string): Video upload date (YYYYMMDD)uploader_id(string): Nickname or id of the video uploaderchannel(string): Full name of the channel the video is uploaded onchannel_id(string): Id of the channellocation(string): Physical location where the video was filmedduration(numeric): Length of the video in secondsview_count(numeric): How many users have watched the video on the platformlike_count(numeric): Number of positive ratings of the videodislike_count(numeric): Number of negative ratings of the videorepost_count(numeric): Number of reposts of the videoaverage_rating(numeric): Average rating give by users, the scale used depends on the webpagecomment_count(numeric): Number of comments on the videoage_limit(numeric): Age restriction for the video (years)is_live(boolean): Whether this video is a live stream or a fixed-length videostart_time(numeric): Time in seconds where the reproduction should start, as specified in the URLend_time(numeric): Time in seconds where the reproduction should end, as specified in the URLformat(string): A human-readable description of the formatformat_id(string): Format code specified by --formatformat_note(string): Additional info about the formatwidth(numeric): Width of the videoheight(numeric): Height of the videoresolution(string): Textual description of width and heighttbr(numeric): Average bitrate of audio and video in KBit/sabr(numeric): Average audio bitrate in KBit/sacodec(string): Name of the audio codec in useasr(numeric): Audio sampling rate in Hertzvbr(numeric): Average video bitrate in KBit/sfps(numeric): Frame ratevcodec(string): Name of the video codec in usecontainer(string): Name of the container formatfilesize(numeric): The number of bytes, if known in advancefilesize_approx(numeric): An estimate for the number of bytesprotocol(string): The protocol that will be used for the actual downloadextractor(string): Name of the extractorextractor_key(string): Key name of the extractorepoch(numeric): Unix epoch when creating the fileautonumber(numeric): Five-digit number that will be increased with each download, starting at zeroplaylist(string): Name or id of the playlist that contains the videoplaylist_index(numeric): Index of the video in the playlist padded with leading zeros according to the total length of the playlistplaylist_id(string): Playlist identifierplaylist_title(string): Playlist titleplaylist_uploader(string): Full name of the playlist uploaderplaylist_uploader_id(string): Nickname or id of the playlist uploaderTELECHARGER LES SOUS TITRES
avec youtube-dl
Liste des sous-titres disponibles :
youtube-dl --list-subs url_de_la_vidéo [youtube] 'référence de la vidéo': Available subtitles for video: en
Télécharger la vidéo avec les sous-titres (exemple en français) :
youtube-dl --write-sub --sub-lang 'fr' url_de_la_vidéo
Pour ne télécharger que les sous-titres sans la vidéo :
youtube-dl --all-subs --skip-download Ye8mB6VsUHw
Options des sous-titres :
--write-subtélécharger les sous-titres--write-auto-subtélécharger les sous-titres automatiques (YouTube)--all-substélécharger tous les sous-titres--list-subsliste des sous-titres disponibles--sub-format FORMATformat du fichier : srt ou ass/srt/best--sub-lang LANGSlangue du sous-titre séparé par une virgule :‘en,fr’avec gcap
sudo apt install gcap
Les fichiers sont enregistrés au format Subrip (srt) de cette manière :
$videoid_$langid.srtgcap 0QRO3gKj3qw gcap "http://www.youtube.com/watch?v=0QRO3gKj3qw" gcap -ti 0QRO3gKj3qw # on utilise le titre comme nom de fichier
En règle générale :
gcap -ti -r <regexp> <url>
Voir aussi : umph - grake - cclive - clive
MODULE PYTHON
import youtube_dl ydl = youtube_dl.YoutubeDL({'outtmpl': '%(title)s%(ext)s'}) with ydl: result = ydl.extract_info( 'http://www.youtube.com/watch?v=BaW_jenozKc', download=False # si on ne veut que des infos, sinon True ) # pour afficher toutes les infos if 'entries' in result: # si une playlist ou une liste de vidéos video = result['entries'][0] else: # Juste une video video = result print(video) print(video['url'])
ydl_opts = { 'format': 'bestaudio/best', 'download_archive': 'downloaded_songs.txt', 'outtmpl': '%(title)s.%(ext)s', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], 'logger': MyLogger(), 'progress_hooks': [my_hook], }
toutes les options : https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/YoutubeDL.py#L128-L278
dossier de sortie :
'outtmpl': '/chemin/vers/%(title)s.%(ext)s'
—