From e7a8c3032d8610bc429b6318678387433728b2a9 Mon Sep 17 00:00:00 2001 From: remitamine Date: Thu, 3 Sep 2015 22:25:33 +0100 Subject: [PATCH 1/4] [downloader/external] Respect --no-check-certificate for curl and aria2c and --proxy for curl --- youtube_dl/downloader/external.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 6c310346c..072ac3a46 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -47,7 +47,7 @@ def supports(cls, info_dict): def _option(self, command_option, param): param = self.params.get(param) - if param is None: + if param is None or param is False: return [] if isinstance(param, bool): return [command_option] @@ -80,6 +80,8 @@ def _make_cmd(self, tmpfilename, info_dict): for key, val in info_dict['http_headers'].items(): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--interface', 'source_address') + cmd += self._option('--proxy', 'proxy') + cmd += self._option('--insecure', 'nocheckcertificate') cmd += self._configuration_args() cmd += ['--', info_dict['url']] return cmd @@ -121,6 +123,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--interface', 'source_address') cmd += self._option('--all-proxy', 'proxy') + cmd += self._option('--check-certificate=false', 'nocheckcertificate') cmd += ['--', info_dict['url']] return cmd From 266b0ad6762eaa48156b021094126062cb9f44d6 Mon Sep 17 00:00:00 2001 From: remitamine Date: Fri, 4 Sep 2015 20:07:36 +0100 Subject: [PATCH 2/4] [downloader/external] add _bool_option to pass value to bool option --- youtube_dl/downloader/external.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 072ac3a46..22dfd2833 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -53,6 +53,14 @@ def _option(self, command_option, param): return [command_option] return [command_option, param] + def _bool_option(self, command_option, param, true_value='true', false_value='false', separator=None): + param = self.params.get(param) + if not isinstance(param, bool): + return [] + if separator: + return [command_option + separator + (true_value if param else false_value)] + return [command_option, true_value if param else false_value] + def _configuration_args(self, default=[]): ex_args = self.params.get('external_downloader_args') if ex_args is None: @@ -123,7 +131,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--interface', 'source_address') cmd += self._option('--all-proxy', 'proxy') - cmd += self._option('--check-certificate=false', 'nocheckcertificate') + cmd += self._bool_option('--check-certificate', 'nocheckcertificate', 'false', 'true', '=') cmd += ['--', info_dict['url']] return cmd From f30c2e8e9867373815aaaa2285f23524a67da730 Mon Sep 17 00:00:00 2001 From: remitamine Date: Fri, 4 Sep 2015 20:57:19 +0100 Subject: [PATCH 3/4] [downloader/external] add _argless_option for option without arguments --- youtube_dl/downloader/external.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 22dfd2833..cae8f6f0f 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -49,8 +49,6 @@ def _option(self, command_option, param): param = self.params.get(param) if param is None or param is False: return [] - if isinstance(param, bool): - return [command_option] return [command_option, param] def _bool_option(self, command_option, param, true_value='true', false_value='false', separator=None): @@ -61,6 +59,10 @@ def _bool_option(self, command_option, param, true_value='true', false_value='fa return [command_option + separator + (true_value if param else false_value)] return [command_option, true_value if param else false_value] + def _argless_option(self, command_option, param, expected_value=True): + param = self.params.get(param) + return [command_option] if param == expected_value else [] + def _configuration_args(self, default=[]): ex_args = self.params.get('external_downloader_args') if ex_args is None: @@ -89,7 +91,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--interface', 'source_address') cmd += self._option('--proxy', 'proxy') - cmd += self._option('--insecure', 'nocheckcertificate') + cmd += self._argless_option('--insecure', 'nocheckcertificate') cmd += self._configuration_args() cmd += ['--', info_dict['url']] return cmd @@ -112,7 +114,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--bind-address', 'source_address') cmd += self._option('--proxy', 'proxy') - cmd += self._option('--no-check-certificate', 'nocheckcertificate') + cmd += self._argless_option('--no-check-certificate', 'nocheckcertificate') cmd += self._configuration_args() cmd += ['--', info_dict['url']] return cmd From dc534b674f9dfbe869d23f6a64ea48f39bde6655 Mon Sep 17 00:00:00 2001 From: remitamine Date: Fri, 4 Sep 2015 21:12:13 +0100 Subject: [PATCH 4/4] [downloader/external] change _argless_option function to _valueless_option --- youtube_dl/downloader/external.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index cae8f6f0f..056215f8c 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -47,7 +47,7 @@ def supports(cls, info_dict): def _option(self, command_option, param): param = self.params.get(param) - if param is None or param is False: + if param is None: return [] return [command_option, param] @@ -59,7 +59,7 @@ def _bool_option(self, command_option, param, true_value='true', false_value='fa return [command_option + separator + (true_value if param else false_value)] return [command_option, true_value if param else false_value] - def _argless_option(self, command_option, param, expected_value=True): + def _valueless_option(self, command_option, param, expected_value=True): param = self.params.get(param) return [command_option] if param == expected_value else [] @@ -91,7 +91,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--interface', 'source_address') cmd += self._option('--proxy', 'proxy') - cmd += self._argless_option('--insecure', 'nocheckcertificate') + cmd += self._valueless_option('--insecure', 'nocheckcertificate') cmd += self._configuration_args() cmd += ['--', info_dict['url']] return cmd @@ -114,7 +114,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--header', '%s: %s' % (key, val)] cmd += self._option('--bind-address', 'source_address') cmd += self._option('--proxy', 'proxy') - cmd += self._argless_option('--no-check-certificate', 'nocheckcertificate') + cmd += self._valueless_option('--no-check-certificate', 'nocheckcertificate') cmd += self._configuration_args() cmd += ['--', info_dict['url']] return cmd