diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-24 03:04:19 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-24 03:24:15 +0530 |
commit | bb66c24797edd8740a27efb8d77669dbb0e859b7 (patch) | |
tree | 651177ab2d75883775606133644884ac0a4900af /yt_dlp/options.py | |
parent | 2edb38e8caa8cadd3a2effd75d8bf47e31f94f9c (diff) | |
download | hypervideo-pre-bb66c24797edd8740a27efb8d77669dbb0e859b7.tar.lz hypervideo-pre-bb66c24797edd8740a27efb8d77669dbb0e859b7.tar.xz hypervideo-pre-bb66c24797edd8740a27efb8d77669dbb0e859b7.zip |
Add option `--print-to-file`
Closes #2372
Diffstat (limited to 'yt_dlp/options.py')
-rw-r--r-- | yt_dlp/options.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/yt_dlp/options.py b/yt_dlp/options.py index 289804945..df8fb6f63 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -173,11 +173,16 @@ def create_parser(): process_key=str.lower, append=False): out_dict = dict(getattr(parser.values, option.dest)) + multiple_args = not isinstance(value, str) if multiple_keys: allowed_keys = r'(%s)(,(%s))*' % (allowed_keys, allowed_keys) - mobj = re.match(r'(?i)(?P<keys>%s)%s(?P<val>.*)$' % (allowed_keys, delimiter), value) + mobj = re.match( + r'(?i)(?P<keys>%s)%s(?P<val>.*)$' % (allowed_keys, delimiter), + value[0] if multiple_args else value) if mobj is not None: keys, val = mobj.group('keys').split(','), mobj.group('val') + if multiple_args: + val = [val, *value[1:]] elif default_key is not None: keys, val = [default_key], value else: @@ -924,6 +929,18 @@ def create_parser(): 'Supported values of "WHEN" are the same as that of --use-postprocessor, and "video" (default). ' 'Implies --quiet and --simulate (unless --no-simulate is used). This option can be used multiple times')) verbosity.add_option( + '--print-to-file', + metavar='[WHEN:]TEMPLATE FILE', dest='print_to_file', default={}, type='str', nargs=2, + action='callback', callback=_dict_from_options_callback, + callback_kwargs={ + 'allowed_keys': 'video|' + '|'.join(map(re.escape, POSTPROCESS_WHEN)), + 'default_key': 'video', + 'multiple_keys': False, + 'append': True, + }, help=( + 'Append given template to the file. The values of WHEN and TEMPLATE are same as that of --print. ' + 'FILE uses the same syntax as the output template. This option can be used multiple times')) + verbosity.add_option( '-g', '--get-url', action='store_true', dest='geturl', default=False, help=optparse.SUPPRESS_HELP) |