Ignore --external-downloader-args if --external-downloader was rejected
authordirkf <fieldhouse@gmx.net>
Tue, 22 Feb 2022 11:24:06 +0000 (11:24 +0000)
committerdirkf <fieldhouse@gmx.net>
Fri, 25 Mar 2022 14:47:26 +0000 (14:47 +0000)
... and generate warning

youtube_dl/YoutubeDL.py
youtube_dl/downloader/__init__.py

index 69736acffa6b32e3c4ac4a9d94c7688bc687ba3f..019e309cb74b9ea3fdd1138e550b60f001d2a96e 100755 (executable)
@@ -1906,8 +1906,17 @@ class YoutubeDL(object):
 
         if not self.params.get('skip_download', False):
             try:
+                def checked_get_suitable_downloader(info_dict, params):
+                    ed_args = params.get('external_downloader_args')
+                    dler = get_suitable_downloader(info_dict, params)
+                    if ed_args and not params.get('external_downloader_args'):
+                        # external_downloader_args was cleared because external_downloader was rejected
+                        self.report_warning('Requested external downloader cannot be used: '
+                                            'ignoring --external-downloader-args.')
+                    return dler
+
                 def dl(name, info):
-                    fd = get_suitable_downloader(info, self.params)(self, self.params)
+                    fd = checked_get_suitable_downloader(info, self.params)(self, self.params)
                     for ph in self._progress_hooks:
                         fd.add_progress_hook(ph)
                     if self.params.get('verbose'):
index d8f2fa3422678d0fb0fda4e5c12eba9a3990fe4b..d701d6292212dc6a761a1da2760378517957542d 100644 (file)
@@ -50,6 +50,9 @@ def _get_suitable_downloader(info_dict, params={}):
         ed = get_external_downloader(external_downloader)
         if ed.can_download(info_dict):
             return ed
+        # Avoid using unwanted args since external_downloader was rejected
+        if params.get('external_downloader_args'):
+            params['external_downloader_args'] = None
 
     protocol = info_dict['protocol']
     if protocol.startswith('m3u8') and info_dict.get('is_live'):