diff options
author | pukkandan <pukkandan@gmail.com> | 2021-01-23 15:13:51 +0530 |
---|---|---|
committer | pukkandan <pukkandan@gmail.com> | 2021-01-23 17:00:11 +0530 |
commit | eab9b2bcafb42c47248f60ef0fdac14389693dd4 (patch) | |
tree | 1b145bf55b51f2846cd924a5eea263676718df8e /youtube_dlc/utils.py | |
parent | 3bcaa37b1beb145d4c21e5932b0b91237a40f967 (diff) | |
download | hypervideo-pre-eab9b2bcafb42c47248f60ef0fdac14389693dd4.tar.lz hypervideo-pre-eab9b2bcafb42c47248f60ef0fdac14389693dd4.tar.xz hypervideo-pre-eab9b2bcafb42c47248f60ef0fdac14389693dd4.zip |
Modified function `cli_configuration_args`
to directly parse new format of `postprocessor_args` and `external_downloader_args`
Diffstat (limited to 'youtube_dlc/utils.py')
-rw-r--r-- | youtube_dlc/utils.py | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/youtube_dlc/utils.py b/youtube_dlc/utils.py index 8cecaa8ee..1ec30bafd 100644 --- a/youtube_dlc/utils.py +++ b/youtube_dlc/utils.py @@ -4656,12 +4656,35 @@ def cli_valueless_option(params, command_option, param, expected_value=True): return [command_option] if param == expected_value else [] -def cli_configuration_args(params, param, default=[]): - ex_args = params.get(param) - if ex_args is None: - return default - assert isinstance(ex_args, list) - return ex_args +def cli_configuration_args(params, arg_name, key, default=[], exe=None): # returns arg, for_compat + argdict = params.get(arg_name, {}) + if isinstance(argdict, (list, tuple)): # for backward compatibility + return argdict, True + + if argdict is None: + return default, False + assert isinstance(argdict, dict) + + assert isinstance(key, compat_str) + key = key.lower() + + args = exe_args = None + if exe is not None: + assert isinstance(exe, compat_str) + exe = exe.lower() + args = argdict.get('%s+%s' % (key, exe)) + if args is None: + exe_args = argdict.get(exe) + + if args is None: + args = argdict.get(key) if key != exe else None + if args is None and exe_args is None: + args = argdict.get('default', default) + + args, exe_args = args or [], exe_args or [] + assert isinstance(args, (list, tuple)) + assert isinstance(exe_args, (list, tuple)) + return args + exe_args, False class ISO639Utils(object): |