mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 02:25:11 +00:00
[downloader/external] add _argless_option for option without arguments
This commit is contained in:
parent
266b0ad676
commit
f30c2e8e98
1 changed files with 6 additions and 4 deletions
|
@ -49,8 +49,6 @@ def _option(self, command_option, param):
|
||||||
param = self.params.get(param)
|
param = self.params.get(param)
|
||||||
if param is None or param is False:
|
if param is None or param is False:
|
||||||
return []
|
return []
|
||||||
if isinstance(param, bool):
|
|
||||||
return [command_option]
|
|
||||||
return [command_option, param]
|
return [command_option, param]
|
||||||
|
|
||||||
def _bool_option(self, command_option, param, true_value='true', false_value='false', separator=None):
|
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 + separator + (true_value if param else false_value)]
|
||||||
return [command_option, 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=[]):
|
def _configuration_args(self, default=[]):
|
||||||
ex_args = self.params.get('external_downloader_args')
|
ex_args = self.params.get('external_downloader_args')
|
||||||
if ex_args is None:
|
if ex_args is None:
|
||||||
|
@ -89,7 +91,7 @@ def _make_cmd(self, tmpfilename, info_dict):
|
||||||
cmd += ['--header', '%s: %s' % (key, val)]
|
cmd += ['--header', '%s: %s' % (key, val)]
|
||||||
cmd += self._option('--interface', 'source_address')
|
cmd += self._option('--interface', 'source_address')
|
||||||
cmd += self._option('--proxy', 'proxy')
|
cmd += self._option('--proxy', 'proxy')
|
||||||
cmd += self._option('--insecure', 'nocheckcertificate')
|
cmd += self._argless_option('--insecure', 'nocheckcertificate')
|
||||||
cmd += self._configuration_args()
|
cmd += self._configuration_args()
|
||||||
cmd += ['--', info_dict['url']]
|
cmd += ['--', info_dict['url']]
|
||||||
return cmd
|
return cmd
|
||||||
|
@ -112,7 +114,7 @@ def _make_cmd(self, tmpfilename, info_dict):
|
||||||
cmd += ['--header', '%s: %s' % (key, val)]
|
cmd += ['--header', '%s: %s' % (key, val)]
|
||||||
cmd += self._option('--bind-address', 'source_address')
|
cmd += self._option('--bind-address', 'source_address')
|
||||||
cmd += self._option('--proxy', 'proxy')
|
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 += self._configuration_args()
|
||||||
cmd += ['--', info_dict['url']]
|
cmd += ['--', info_dict['url']]
|
||||||
return cmd
|
return cmd
|
||||||
|
|
Loading…
Reference in a new issue