X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/f89b3e2d7ab7a6e28fc1d9975aa4e998b165c090..0ba692acc8feffd46b6e1085fb4a2849b685945c:/yt_dlp/options.py diff --git a/yt_dlp/options.py b/yt_dlp/options.py index b26d43d2a..f9201bf01 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -137,7 +137,11 @@ def _dict_from_options_callback( else: raise optparse.OptionValueError( 'wrong %s formatting; it should be %s, not "%s"' % (opt_str, option.metavar, value)) - val = process(val) if callable(process) else val + try: + val = process(val) if process else val + except Exception as err: + raise optparse.OptionValueError( + 'wrong %s formatting; %s' % (opt_str, err)) for key in keys: out_dict[key] = val @@ -520,8 +524,12 @@ def _dict_from_options_callback( help="Don't give any special preference to free containers (default)") video_format.add_option( '--check-formats', - action='store_true', dest='check_formats', default=False, - help="Check that the formats selected are actually downloadable (Experimental)") + action='store_true', dest='check_formats', default=None, + help='Check that the formats selected are actually downloadable') + video_format.add_option( + '--no-check-formats', + action='store_false', dest='check_formats', + help='Do not check that the formats selected are actually downloadable') video_format.add_option( '-F', '--list-formats', action='store_true', dest='listformats', @@ -599,6 +607,10 @@ def _dict_from_options_callback( '-r', '--limit-rate', '--rate-limit', dest='ratelimit', metavar='RATE', help='Maximum download rate in bytes per second (e.g. 50K or 4.2M)') + downloader.add_option( + '--throttled-rate', + dest='throttledratelimit', metavar='RATE', + help='Minimum download rate in bytes per second below which throttling is assumed and the video data is re-extracted (e.g. 100K)') downloader.add_option( '-R', '--retries', dest='retries', metavar='RETRIES', default=10, @@ -712,7 +724,8 @@ def _dict_from_options_callback( help=( 'Give these arguments to the external downloader. ' 'Specify the downloader name and the arguments separated by a colon ":". ' - 'You can use this option multiple times (Alias: --external-downloader-args)')) + 'You can use this option multiple times to give different arguments to different downloaders ' + '(Alias: --external-downloader-args)')) workarounds = optparse.OptionGroup(parser, 'Workarounds') workarounds.add_option( @@ -1165,7 +1178,7 @@ def _dict_from_options_callback( 'to give the argument to the specified postprocessor/executable. Supported PP are: ' 'Merger, ExtractAudio, SplitChapters, Metadata, EmbedSubtitle, EmbedThumbnail, ' 'SubtitlesConvertor, ThumbnailsConvertor, VideoRemuxer, VideoConvertor, ' - 'SponSkrub, FixupStretched, FixupM4a and FixupM3u8. ' + 'SponSkrub, FixupStretched, FixupM4a, FixupM3u8, FixupTimestamp and FixupDuration. ' 'The supported executables are: AtomicParsley, FFmpeg, FFprobe, and SponSkrub. ' 'You can also specify "PP+EXE:ARGS" to give the arguments to the specified executable ' 'only when being used by the specified postprocessor. Additionally, for ffmpeg/ffprobe, ' @@ -1200,19 +1213,19 @@ def _dict_from_options_callback( postproc.add_option( '--embed-thumbnail', action='store_true', dest='embedthumbnail', default=False, - help='Embed thumbnail in the video/audio as cover art') + help='Embed thumbnail in the video as cover art') postproc.add_option( '--no-embed-thumbnail', action='store_false', dest='embedthumbnail', help='Do not embed thumbnail (default)') postproc.add_option( - '--add-metadata', + '--embed-metadata', '--add-metadata', action='store_true', dest='addmetadata', default=False, - help='Write metadata to the video file') + help='Embed metadata including chapter markers (if supported by the format) to the video file (Alias: --add-metadata)') postproc.add_option( - '--no-add-metadata', + '--no-embed-metadata', '--no-add-metadata', action='store_false', dest='addmetadata', - help='Do not write metadata (default)') + help='Do not write metadata (default) (Alias: --no-add-metadata)') postproc.add_option( '--metadata-from-title', metavar='FORMAT', dest='metafromtitle', @@ -1256,6 +1269,10 @@ def _dict_from_options_callback( 'Similar syntax to the output template can be used to pass any field as arguments to the command. ' 'An additional field "filepath" that contains the final path of the downloaded file is also available. ' 'If no fields are passed, "%(filepath)s" is appended to the end of the command')) + postproc.add_option( + '--exec-before-download', + metavar='CMD', dest='exec_before_dl_cmd', + help='Execute a command before the actual download. The syntax is the same as --exec') postproc.add_option( '--convert-subs', '--convert-sub', '--convert-subtitles', metavar='FORMAT', dest='convertsubtitles', default=None, @@ -1339,22 +1356,35 @@ def _dict_from_options_callback( '--no-hls-split-discontinuity', dest='hls_split_discontinuity', action='store_false', help='Do not split HLS playlists to different formats at discontinuities such as ad breaks (default)') + _extractor_arg_parser = lambda key, vals='': (key.strip().lower(), [val.strip() for val in vals.split(',')]) + extractor.add_option( + '--extractor-args', + metavar='KEY:ARGS', dest='extractor_args', default={}, type='str', + action='callback', callback=_dict_from_options_callback, + callback_kwargs={ + 'multiple_keys': False, + 'process': lambda val: dict( + _extractor_arg_parser(*arg.split('=', 1)) for arg in val.split(';')) + }, + help=( + 'Pass these arguments to the extractor. See "EXTRACTOR ARGUMENTS" for details. ' + 'You can use this option multiple times to give arguments for different extractors')) extractor.add_option( '--youtube-include-dash-manifest', '--no-youtube-skip-dash-manifest', action='store_true', dest='youtube_include_dash_manifest', default=True, - help='Download the DASH manifests and related data on YouTube videos (default) (Alias: --no-youtube-skip-dash-manifest)') + help=optparse.SUPPRESS_HELP) extractor.add_option( '--youtube-skip-dash-manifest', '--no-youtube-include-dash-manifest', action='store_false', dest='youtube_include_dash_manifest', - help='Do not download the DASH manifests and related data on YouTube videos (Alias: --no-youtube-include-dash-manifest)') + help=optparse.SUPPRESS_HELP) extractor.add_option( '--youtube-include-hls-manifest', '--no-youtube-skip-hls-manifest', action='store_true', dest='youtube_include_hls_manifest', default=True, - help='Download the HLS manifests and related data on YouTube videos (default) (Alias: --no-youtube-skip-hls-manifest)') + help=optparse.SUPPRESS_HELP) extractor.add_option( '--youtube-skip-hls-manifest', '--no-youtube-include-hls-manifest', action='store_false', dest='youtube_include_hls_manifest', - help='Do not download the HLS manifests and related data on YouTube videos (Alias: --no-youtube-include-hls-manifest)') + help=optparse.SUPPRESS_HELP) parser.add_option_group(general) parser.add_option_group(network)