Standardized function for creating dict from repeated options
This commit is contained in:
@@ -70,14 +70,7 @@ def _real_main(argv=None):
|
||||
std_headers['Referer'] = opts.referer
|
||||
|
||||
# Custom HTTP headers
|
||||
if opts.headers is not None:
|
||||
for h in opts.headers:
|
||||
if ':' not in h:
|
||||
parser.error('wrong header formatting, it should be key:value, not "%s"' % h)
|
||||
key, value = h.split(':', 1)
|
||||
if opts.verbose:
|
||||
write_string('[debug] Adding header from command line option %s:%s\n' % (key, value))
|
||||
std_headers[key] = value
|
||||
std_headers.update(opts.headers)
|
||||
|
||||
# Dump user agent
|
||||
if opts.dump_user_agent:
|
||||
@@ -337,21 +330,9 @@ def _real_main(argv=None):
|
||||
if opts.external_downloader_args:
|
||||
external_downloader_args = compat_shlex_split(opts.external_downloader_args)
|
||||
|
||||
postprocessor_args = {}
|
||||
if opts.postprocessor_args is not None:
|
||||
for string in opts.postprocessor_args:
|
||||
mobj = re.match(r'(?P<pp>\w+(?:\+\w+)?):(?P<args>.*)$', string)
|
||||
if mobj is None:
|
||||
if 'sponskrub' not in postprocessor_args: # for backward compatibility
|
||||
postprocessor_args['sponskrub'] = []
|
||||
if opts.verbose:
|
||||
write_string('[debug] Adding postprocessor args from command line option sponskrub: \n')
|
||||
pp_key, pp_args = 'default', string
|
||||
else:
|
||||
pp_key, pp_args = mobj.group('pp').lower(), mobj.group('args')
|
||||
if opts.verbose:
|
||||
write_string('[debug] Adding postprocessor args from command line option %s: %s\n' % (pp_key, pp_args))
|
||||
postprocessor_args[pp_key] = compat_shlex_split(pp_args)
|
||||
if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args:
|
||||
opts.postprocessor_args.setdefault('sponskrub', [])
|
||||
opts.postprocessor_args['default'] = opts.postprocessor_args['default-compat']
|
||||
|
||||
match_filter = (
|
||||
None if opts.match_filter is None
|
||||
@@ -486,7 +467,7 @@ def _real_main(argv=None):
|
||||
'hls_prefer_native': opts.hls_prefer_native,
|
||||
'hls_use_mpegts': opts.hls_use_mpegts,
|
||||
'external_downloader_args': external_downloader_args,
|
||||
'postprocessor_args': postprocessor_args,
|
||||
'postprocessor_args': opts.postprocessor_args,
|
||||
'cn_verification_proxy': opts.cn_verification_proxy,
|
||||
'geo_verification_proxy': opts.geo_verification_proxy,
|
||||
'config_location': opts.config_location,
|
||||
|
||||
Reference in New Issue
Block a user