diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-05-19 19:45:21 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-05-19 19:45:21 +0530 |
commit | 9e491463521c65ca4d1d44a757e0a115f62834f5 (patch) | |
tree | 1caf801ceb17d12fc1c4b8beacd54e05fff29524 /yt_dlp/utils.py | |
parent | 926ccc84ef91498f3147b07d15eb5f40cd070471 (diff) | |
download | hypervideo-pre-9e491463521c65ca4d1d44a757e0a115f62834f5.tar.lz hypervideo-pre-9e491463521c65ca4d1d44a757e0a115f62834f5.tar.xz hypervideo-pre-9e491463521c65ca4d1d44a757e0a115f62834f5.zip |
Add option `--alias`
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index bcdb7d55b..f02f71177 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -5153,11 +5153,12 @@ def parse_http_range(range): class Config: own_args = None + parsed_args = None filename = None __initialized = False def __init__(self, parser, label=None): - self._parser, self.label = parser, label + self.parser, self.label = parser, label self._loaded_paths, self.configs = set(), [] def init(self, args=None, filename=None): @@ -5170,14 +5171,16 @@ class Config: return False self._loaded_paths.add(location) - self.__initialized = True - self.own_args, self.filename = args, filename - for location in self._parser.parse_args(args)[0].config_locations or []: + self.own_args, self.__initialized = args, True + opts, _ = self.parser.parse_known_args(args) + self.parsed_args, self.filename = args, filename + + for location in opts.config_locations or []: location = os.path.join(directory, expand_path(location)) if os.path.isdir(location): location = os.path.join(location, 'yt-dlp.conf') if not os.path.exists(location): - self._parser.error(f'config location {location} does not exist') + self.parser.error(f'config location {location} does not exist') self.append_config(self.read_file(location), location) return True @@ -5223,7 +5226,7 @@ class Config: return opts def append_config(self, *args, label=None): - config = type(self)(self._parser, label) + config = type(self)(self.parser, label) config._loaded_paths = self._loaded_paths if config.init(*args): self.configs.append(config) @@ -5232,10 +5235,13 @@ class Config: def all_args(self): for config in reversed(self.configs): yield from config.all_args - yield from self.own_args or [] + yield from self.parsed_args or [] + + def parse_known_args(self, **kwargs): + return self.parser.parse_known_args(self.all_args, **kwargs) def parse_args(self): - return self._parser.parse_args(self.all_args) + return self.parser.parse_args(self.all_args) class WebSocketsWrapper(): |