mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-27 21:59:17 +01:00
Allow passing different arguments to different external downloaders
* Now similar to --post-processor-args * Also added `--downloader-args` as alias to `--external-downloader-args`
This commit is contained in:
parent
45016689fa
commit
46ee996e39
4 changed files with 32 additions and 15 deletions
13
README.md
13
README.md
|
@ -303,11 +303,14 @@ Then simply type this
|
||||||
allowing to play the video while
|
allowing to play the video while
|
||||||
downloading (some players may not be able
|
downloading (some players may not be able
|
||||||
to play it)
|
to play it)
|
||||||
--external-downloader COMMAND Use the specified external downloader.
|
--external-downloader NAME Use the specified external downloader.
|
||||||
Currently supports
|
Currently supports aria2c, avconv, axel,
|
||||||
aria2c,avconv,axel,curl,ffmpeg,httpie,wget
|
curl, ffmpeg, httpie, wget
|
||||||
--external-downloader-args ARGS Give these arguments to the external
|
--downloader-args NAME:ARGS Give these arguments to the external
|
||||||
downloader
|
downloader. Specify the downloader name and
|
||||||
|
the arguments separated by a colon ":". You
|
||||||
|
can use this option multiple times (Alias:
|
||||||
|
--external-downloader-args)
|
||||||
|
|
||||||
## Filesystem Options:
|
## Filesystem Options:
|
||||||
-a, --batch-file FILE File containing URLs to download ('-' for
|
-a, --batch-file FILE File containing URLs to download ('-' for
|
||||||
|
|
|
@ -326,9 +326,6 @@ def _real_main(argv=None):
|
||||||
'key': 'ExecAfterDownload',
|
'key': 'ExecAfterDownload',
|
||||||
'exec_cmd': opts.exec_cmd,
|
'exec_cmd': opts.exec_cmd,
|
||||||
})
|
})
|
||||||
external_downloader_args = None
|
|
||||||
if opts.external_downloader_args:
|
|
||||||
external_downloader_args = compat_shlex_split(opts.external_downloader_args)
|
|
||||||
|
|
||||||
if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args:
|
if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args:
|
||||||
opts.postprocessor_args.setdefault('sponskrub', [])
|
opts.postprocessor_args.setdefault('sponskrub', [])
|
||||||
|
@ -466,7 +463,7 @@ def _real_main(argv=None):
|
||||||
'ffmpeg_location': opts.ffmpeg_location,
|
'ffmpeg_location': opts.ffmpeg_location,
|
||||||
'hls_prefer_native': opts.hls_prefer_native,
|
'hls_prefer_native': opts.hls_prefer_native,
|
||||||
'hls_use_mpegts': opts.hls_use_mpegts,
|
'hls_use_mpegts': opts.hls_use_mpegts,
|
||||||
'external_downloader_args': external_downloader_args,
|
'external_downloader_args': opts.external_downloader_args,
|
||||||
'postprocessor_args': opts.postprocessor_args,
|
'postprocessor_args': opts.postprocessor_args,
|
||||||
'cn_verification_proxy': opts.cn_verification_proxy,
|
'cn_verification_proxy': opts.cn_verification_proxy,
|
||||||
'geo_verification_proxy': opts.geo_verification_proxy,
|
'geo_verification_proxy': opts.geo_verification_proxy,
|
||||||
|
|
|
@ -95,7 +95,19 @@ class ExternalFD(FileDownloader):
|
||||||
return cli_valueless_option(self.params, command_option, param, expected_value)
|
return cli_valueless_option(self.params, command_option, param, expected_value)
|
||||||
|
|
||||||
def _configuration_args(self, default=[]):
|
def _configuration_args(self, default=[]):
|
||||||
return cli_configuration_args(self.params, 'external_downloader_args', default)
|
args = self.params.get('external_downloader_args', {})
|
||||||
|
if isinstance(args, (list, tuple)): # for backward compatibility
|
||||||
|
return args
|
||||||
|
if args is None:
|
||||||
|
return default
|
||||||
|
assert isinstance(args, dict)
|
||||||
|
|
||||||
|
dl_args = args.get(self.get_basename().lower())
|
||||||
|
if dl_args is None:
|
||||||
|
dl_args = args.get('default', default)
|
||||||
|
assert isinstance(dl_args, (list, tuple))
|
||||||
|
return dl_args
|
||||||
|
|
||||||
|
|
||||||
def _call_downloader(self, tmpfilename, info_dict):
|
def _call_downloader(self, tmpfilename, info_dict):
|
||||||
""" Either overwrite this or implement _make_cmd """
|
""" Either overwrite this or implement _make_cmd """
|
||||||
|
|
|
@ -632,14 +632,19 @@ def parseOpts(overrideArguments=None):
|
||||||
'video while downloading (some players may not be able to play it)'))
|
'video while downloading (some players may not be able to play it)'))
|
||||||
downloader.add_option(
|
downloader.add_option(
|
||||||
'--external-downloader',
|
'--external-downloader',
|
||||||
dest='external_downloader', metavar='COMMAND',
|
dest='external_downloader', metavar='NAME',
|
||||||
help=(
|
help=(
|
||||||
'Use the specified external downloader. '
|
'Use the specified external downloader. '
|
||||||
'Currently supports %s' % ','.join(list_external_downloaders())))
|
'Currently supports %s' % ', '.join(list_external_downloaders())))
|
||||||
downloader.add_option(
|
downloader.add_option(
|
||||||
'--external-downloader-args',
|
'--downloader-args', '--external-downloader-args',
|
||||||
dest='external_downloader_args', metavar='ARGS',
|
metavar='NAME:ARGS', dest='external_downloader_args', default={}, type='str',
|
||||||
help='Give these arguments to the external downloader')
|
action='callback', callback=_dict_from_multiple_values_options_callback,
|
||||||
|
callback_kwargs={'default_key': 'default', 'process': compat_shlex_split},
|
||||||
|
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)'))
|
||||||
|
|
||||||
workarounds = optparse.OptionGroup(parser, 'Workarounds')
|
workarounds = optparse.OptionGroup(parser, 'Workarounds')
|
||||||
workarounds.add_option(
|
workarounds.add_option(
|
||||||
|
|
Loading…
Reference in a new issue