]> jfr.im git - yt-dlp.git/commitdiff
Allow passing different arguments to different external downloaders
authorpukkandan <redacted>
Sat, 23 Jan 2021 05:59:20 +0000 (11:29 +0530)
committerpukkandan <redacted>
Sat, 23 Jan 2021 11:30:10 +0000 (17:00 +0530)
* Now similar to --post-processor-args
* Also added `--downloader-args` as alias to `--external-downloader-args`

README.md
youtube_dlc/__init__.py
youtube_dlc/downloader/external.py
youtube_dlc/options.py

index ebfad3781d6c31d985ae45ef297c1775f7e6ddb3..2da25b2009f287bceaa283c2eae25e8c6acbc1ee 100644 (file)
--- a/README.md
+++ b/README.md
@@ -303,11 +303,14 @@ ## Download Options:
                                      allowing to play the video while
                                      downloading (some players may not be able
                                      to play it)
-    --external-downloader COMMAND    Use the specified external downloader.
-                                     Currently supports
-                                     aria2c,avconv,axel,curl,ffmpeg,httpie,wget
-    --external-downloader-args ARGS  Give these arguments to the external
-                                     downloader
+    --external-downloader NAME       Use the specified external downloader.
+                                     Currently supports aria2c, avconv, axel,
+                                     curl, ffmpeg, httpie, wget
+    --downloader-args NAME:ARGS      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)
 
 ## Filesystem Options:
     -a, --batch-file FILE            File containing URLs to download ('-' for
index 01b1a347b27f7b096df9b8213d22431ce5edab52..c58fb7563f1af2bebdbc3a1d2cc58b181987aa3d 100644 (file)
@@ -326,9 +326,6 @@ def parse_retries(retries):
             'key': 'ExecAfterDownload',
             '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:
         opts.postprocessor_args.setdefault('sponskrub', [])
@@ -466,7 +463,7 @@ def parse_retries(retries):
         'ffmpeg_location': opts.ffmpeg_location,
         'hls_prefer_native': opts.hls_prefer_native,
         '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,
         'cn_verification_proxy': opts.cn_verification_proxy,
         'geo_verification_proxy': opts.geo_verification_proxy,
index 8cd0511fc800966b395ad6b620b812ab297b87b1..2ae153f4ab265bd502f2cb55cb29b2f719ad5224 100644 (file)
@@ -95,7 +95,19 @@ def _valueless_option(self, command_option, param, expected_value=True):
         return cli_valueless_option(self.params, command_option, param, expected_value)
 
     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):
         """ Either overwrite this or implement _make_cmd """
index 3e7be145106c10037847c38a8411759b7674b96c..cb8e8c06ddfea2b589be90e2827ef84ec182a63b 100644 (file)
@@ -632,14 +632,19 @@ def _dict_from_multiple_values_options_callback(
             'video while downloading (some players may not be able to play it)'))
     downloader.add_option(
         '--external-downloader',
-        dest='external_downloader', metavar='COMMAND',
+        dest='external_downloader', metavar='NAME',
         help=(
             'Use the specified external downloader. '
-            'Currently supports %s' % ','.join(list_external_downloaders())))
+            'Currently supports %s' % ', '.join(list_external_downloaders())))
     downloader.add_option(
-        '--external-downloader-args',
-        dest='external_downloader_args', metavar='ARGS',
-        help='Give these arguments to the external downloader')
+        '--downloader-args', '--external-downloader-args',
+        metavar='NAME:ARGS', dest='external_downloader_args', default={}, type='str',
+        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.add_option(