Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'retries': 9001,
'fragment_retries': 9001,
'forcejson': True,
'writeinfojson': True,
'writedescription': True,
'writethumbnail': True,
'writeannotations': True,
'writesubtitles': True,
'allsubtitles': True,
'ignoreerrors': True, ## Geo-blocked, copyrighted/private/deleted will be printed to STDOUT and channel ripping will continue uninterupted, use with verbose off
'fixup': 'warn', ## Slightly more verbosity for debugging problems
'nooverwrites': True, ## Don't touch what's already been downloaded, speeds things
'consoletitle': True, ## Download percentage in console title
'prefer_ffmpeg': True, ## ffmpeg is better than avconv, let's prefer it's use
'call_home': True, ## Warns on out of date youtube-dl script, helps debugging for youtube-dl devs
'logger': MyLogger(),
'progress_hooks': [my_hook]
}
if proxy_url is not None: # use proxy url as argument
ydl_opts['proxy'] = proxy_url
# format: We don't set a default format. Youtube-dl will choose the best option for us automatically.
# Since the end of April 2015 and version 2015.04.26 youtube-dl uses -f bestvideo+bestaudio/best as default format selection (see #5447, #5456).
# If ffmpeg or avconv are installed this results in downloading bestvideo and bestaudio separately and muxing them together into a single file giving the best overall quality available.
# Otherwise it falls back to best and results in downloading best available quality served as a single file.
# best is also needed for videos that don't come from YouTube because they don't provide the audio and video in two different files.
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(URLs)