X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/18e674b4f6bc738288b989d8b6a5f5698662a13b..5d3a0e794b50a7f2524bdf37a886e0f436eb2f14:/yt_dlp/__init__.py diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index e7c1c34e4..fd7729ee6 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # coding: utf-8 from __future__ import unicode_literals @@ -24,6 +24,7 @@ DateRange, decodeOption, DownloadError, + error_to_compat_str, ExistingVideoReached, expand_path, match_filter_func, @@ -37,7 +38,7 @@ std_headers, write_string, ) -from .update import update_self +from .update import run_update from .downloader import ( FileDownloader, ) @@ -150,6 +151,11 @@ def _real_main(argv=None): if numeric_limit is None: parser.error('invalid rate limit specified') opts.ratelimit = numeric_limit + if opts.throttledratelimit is not None: + numeric_limit = FileDownloader.parse_bytes(opts.throttledratelimit) + if numeric_limit is None: + parser.error('invalid rate limit specified') + opts.throttledratelimit = numeric_limit if opts.min_filesize is not None: numeric_limit = FileDownloader.parse_bytes(opts.min_filesize) if numeric_limit is None: @@ -267,6 +273,7 @@ def parse_compat_opts(): 'filename', 'format-sort', 'abort-on-error', 'format-spec', 'no-playlist-metafiles', 'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge', 'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-attach-info-json', + 'embed-thumbnail-atomicparsley', ] compat_opts = parse_compat_opts() @@ -307,6 +314,16 @@ def set_default_compat(compat_name, opt_name, default=True, remove_compat=False) else: _unused_compat_opt('filename') + def validate_outtmpl(tmpl, msg): + err = YoutubeDL.validate_outtmpl(tmpl) + if err: + parser.error('invalid %s %r: %s' % (msg, tmpl, error_to_compat_str(err))) + + for k, tmpl in opts.outtmpl.items(): + validate_outtmpl(tmpl, '%s output template' % k) + for tmpl in opts.forceprint: + validate_outtmpl(tmpl, 'print template') + if opts.extractaudio and not opts.keepvideo and opts.format is None: opts.format = 'bestaudio/best' @@ -540,6 +557,7 @@ def report_args_compat(arg, name): 'ignoreerrors': opts.ignoreerrors, 'force_generic_extractor': opts.force_generic_extractor, 'ratelimit': opts.ratelimit, + 'throttledratelimit': opts.throttledratelimit, 'overwrites': opts.overwrites, 'retries': opts.retries, 'fragment_retries': opts.fragment_retries, @@ -613,6 +631,7 @@ def report_args_compat(arg, name): 'include_ads': opts.include_ads, 'default_search': opts.default_search, 'dynamic_mpd': opts.dynamic_mpd, + 'extractor_args': opts.extractor_args, 'youtube_include_dash_manifest': opts.youtube_include_dash_manifest, 'youtube_include_hls_manifest': opts.youtube_include_hls_manifest, 'encoding': opts.encoding, @@ -663,7 +682,7 @@ def report_args_compat(arg, name): # Update version if opts.update_self: # If updater returns True, exit. Required for windows - if update_self(ydl.to_screen, opts.verbose, ydl._opener): + if run_update(ydl): if actual_use: sys.exit('ERROR: The program must exit for the update to complete') sys.exit()