mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-10 00:58:17 +02:00
parent
bf1824b391
commit
44a6fcff39
@ -96,12 +96,16 @@ def load_configs():
|
|||||||
|
|
||||||
opts = optparse.Values({'verbose': True, 'print_help': False})
|
opts = optparse.Values({'verbose': True, 'print_help': False})
|
||||||
try:
|
try:
|
||||||
if overrideArguments:
|
try:
|
||||||
root.append_config(overrideArguments, label='Override')
|
if overrideArguments:
|
||||||
else:
|
root.append_config(overrideArguments, label='Override')
|
||||||
root.append_config(sys.argv[1:], label='Command-line')
|
else:
|
||||||
|
root.append_config(sys.argv[1:], label='Command-line')
|
||||||
|
loaded_all_configs = all(load_configs())
|
||||||
|
except ValueError as err:
|
||||||
|
raise root.parser.error(err)
|
||||||
|
|
||||||
if all(load_configs()):
|
if loaded_all_configs:
|
||||||
# If ignoreconfig is found inside the system configuration file,
|
# If ignoreconfig is found inside the system configuration file,
|
||||||
# the user configuration is removed
|
# the user configuration is removed
|
||||||
if root.parse_known_args()[0].ignoreconfig:
|
if root.parse_known_args()[0].ignoreconfig:
|
||||||
@ -183,7 +187,7 @@ def parse_known_args(self, args=None, values=None, strict=True):
|
|||||||
return self.check_values(self.values, self.largs)
|
return self.check_values(self.values, self.largs)
|
||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg):
|
||||||
msg = f'{self.get_prog_name()}: error: {msg.strip()}\n'
|
msg = f'{self.get_prog_name()}: error: {str(msg).strip()}\n'
|
||||||
raise optparse.OptParseError(f'{self.get_usage()}\n{msg}' if self.usage else msg)
|
raise optparse.OptParseError(f'{self.get_usage()}\n{msg}' if self.usage else msg)
|
||||||
|
|
||||||
def _get_args(self, args):
|
def _get_args(self, args):
|
||||||
|
@ -5420,6 +5420,8 @@ def read_file(filename, default=[]):
|
|||||||
# FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56
|
# FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56
|
||||||
contents = optionf.read()
|
contents = optionf.read()
|
||||||
res = shlex.split(contents, comments=True)
|
res = shlex.split(contents, comments=True)
|
||||||
|
except Exception as err:
|
||||||
|
raise ValueError(f'Unable to parse "{filename}": {err}')
|
||||||
finally:
|
finally:
|
||||||
optionf.close()
|
optionf.close()
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user