Loading

extract_info.py

  1. from youtube_dl import YoutubeDL
  2. import sys
  3. import os
  4. import json
  5.  
  6. if len(sys.argv) <= 1:
  7.     exit()
  8.  
  9. url = sys.argv[1]
  10.  
  11. with YoutubeDL({
  12.         'format': "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio",
  13.         'outtmpl': '%(title)s.%(ext)s',
  14.         'writesubtitles': True,
  15.         'allsubtitles': True,
  16.         'quiet': True,
  17.         'no_warnings': True,
  18.         'noplaylist': True,
  19.         'geo_bypass': True,
  20.     }) as ydl:
  21.     info_dict = ydl.extract_info(url, download=False)
  22.     print(json.dumps(info_dict))

Comments