• 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, faire sudo apt install python

      Si ça ne marche pas, recommencer en remplaçant /usr/local/bin par /usr/bin

       

      usage :

      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_video

      8 - 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

      -t renommer le fichier téléchargé avec le titre

      -F connaître les formats disponibles d’une vidéo

      -f xx télécharger avec le format spécifique xx

      NOM DU FICHIER DE SORTIE

      -o permet d’indiquer le schéma de sortie : %(NAME)s or %(NAME)05d

       

      id (string): Video identifier

      title (string): Video title

      url (string): Video URL

      ext (string): Video filename extension

      alt_title (string): A secondary title of the video

      display_id (string): An alternative identifier for the video

      uploader (string): Full name of the video uploader

      license (string): License name the video is licensed under

      creator (string): The creator of the video

      release_date (string): The date (YYYYMMDD) when the video was released

      timestamp (numeric): UNIX timestamp of the moment the video became available

      upload_date (string): Video upload date (YYYYMMDD)

      uploader_id (string): Nickname or id of the video uploader

      channel (string): Full name of the channel the video is uploaded on

      channel_id (string): Id of the channel

      location (string): Physical location where the video was filmed

      duration (numeric): Length of the video in seconds

      view_count (numeric): How many users have watched the video on the platform

      like_count (numeric): Number of positive ratings of the video

      dislike_count (numeric): Number of negative ratings of the video

      repost_count (numeric): Number of reposts of the video

      average_rating (numeric): Average rating give by users, the scale used depends on the webpage

      comment_count (numeric): Number of comments on the video

      age_limit (numeric): Age restriction for the video (years)

      is_live (boolean): Whether this video is a live stream or a fixed-length video

      start_time (numeric): Time in seconds where the reproduction should start, as specified in the URL

      end_time (numeric): Time in seconds where the reproduction should end, as specified in the URL

      format (string): A human-readable description of the format

      format_id (string): Format code specified by --format

      format_note (string): Additional info about the format

      width (numeric): Width of the video

      height (numeric): Height of the video

      resolution (string): Textual description of width and height

      tbr (numeric): Average bitrate of audio and video in KBit/s

      abr (numeric): Average audio bitrate in KBit/s

      acodec (string): Name of the audio codec in use

      asr (numeric): Audio sampling rate in Hertz

      vbr (numeric): Average video bitrate in KBit/s

      fps (numeric): Frame rate

      vcodec (string): Name of the video codec in use

      container (string): Name of the container format

      filesize (numeric): The number of bytes, if known in advance

      filesize_approx (numeric): An estimate for the number of bytes

      protocol (string): The protocol that will be used for the actual download

      extractor (string): Name of the extractor

      extractor_key (string): Key name of the extractor

      epoch (numeric): Unix epoch when creating the file

      autonumber (numeric): Five-digit number that will be increased with each download, starting at zero

      playlist (string): Name or id of the playlist that contains the video

      playlist_index (numeric): Index of the video in the playlist padded with leading zeros according to the total length of the playlist

      playlist_id (string): Playlist identifier

      playlist_title (string): Playlist title

      playlist_uploader (string): Full name of the playlist uploader

      playlist_uploader_id (string): Nickname or id of the playlist uploader

      TELECHARGER 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-sub télécharger les sous-titres

      --write-auto-sub télécharger les sous-titres automatiques (YouTube)

      --all-subs télécharger tous les sous-titres

      --list-subs liste des sous-titres disponibles

      --sub-format FORMAT format du fichier : srt ou ass/srt/best

      --sub-lang LANGS langue 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.srt

       

      gcap 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'

       

 

Aucun commentaire

 

Laissez un commentaire