mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 09:12:40 +01:00
[downloader/external] Use generalized cli option converters
This commit is contained in:
parent
66e289bab4
commit
1195a38f46
@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
from .common import FileDownloader
|
from .common import FileDownloader
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
cli_option,
|
||||||
|
cli_valueless_option,
|
||||||
|
cli_bool_option,
|
||||||
|
cli_configuration_args,
|
||||||
encodeFilename,
|
encodeFilename,
|
||||||
encodeArgument,
|
encodeArgument,
|
||||||
)
|
)
|
||||||
@ -46,29 +50,16 @@ def supports(cls, info_dict):
|
|||||||
return info_dict['protocol'] in ('http', 'https', 'ftp', 'ftps')
|
return info_dict['protocol'] in ('http', 'https', 'ftp', 'ftps')
|
||||||
|
|
||||||
def _option(self, command_option, param):
|
def _option(self, command_option, param):
|
||||||
param = self.params.get(param)
|
return cli_option(self.params, command_option, param)
|
||||||
if param is None:
|
|
||||||
return []
|
|
||||||
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):
|
||||||
param = self.params.get(param)
|
return cli_bool_option(self.params, command_option, param, true_value, false_value, separator)
|
||||||
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 _valueless_option(self, command_option, param, expected_value=True):
|
def _valueless_option(self, command_option, param, expected_value=True):
|
||||||
param = self.params.get(param)
|
return cli_valueless_option(self.params, command_option, param, expected_value)
|
||||||
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')
|
return cli_configuration_args(self.params, 'external_downloader_args', default)
|
||||||
if ex_args is None:
|
|
||||||
return default
|
|
||||||
assert isinstance(ex_args, list)
|
|
||||||
return ex_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 """
|
||||||
|
Loading…
Reference in New Issue
Block a user