Skip to content

Commit ecf58ed

Browse files
committed
cli: fix order of config file deprecation log msgs
- Don't log when loading a config from a deprecated path when using the `--config` argument - Only load the first existing plugin specific config file - Keep config file loading order
1 parent 7a16ade commit ecf58ed

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/streamlink_cli/main.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,9 @@ def setup_args(parser: argparse.ArgumentParser, config_files: List[Path] = None,
633633
arglist = sys.argv[1:]
634634

635635
# Load arguments from config files
636-
for config_file in filter(lambda path: path.is_file(), config_files or []):
637-
if type(config_file) is DeprecatedPath:
638-
log.info(f"Loaded config from deprecated path, see CLI docs for how to migrate: {config_file}")
639-
arglist.insert(0, f"@{config_file}")
636+
configs = [f"@{config_file}" for config_file in config_files or []]
640637

641-
args, unknown = parser.parse_known_args(arglist)
638+
args, unknown = parser.parse_known_args(configs + arglist)
642639
if unknown and not ignore_unknown:
643640
msg = gettext('unrecognized arguments: %s')
644641
parser.error(msg % ' '.join(unknown))
@@ -654,20 +651,32 @@ def setup_args(parser: argparse.ArgumentParser, config_files: List[Path] = None,
654651
def setup_config_args(parser, ignore_unknown=False):
655652
config_files = []
656653

657-
if streamlink and args.url:
658-
with ignored(NoPluginError):
659-
plugin = streamlink.resolve_url(args.url)
660-
config_files += [path.with_name(f"{path.name}.{plugin.module}") for path in CONFIG_FILES]
661-
662654
if args.config:
663655
# We want the config specified last to get highest priority
664-
config_files += map(lambda path: Path(path).expanduser(), reversed(args.config))
656+
for config_file in map(lambda path: Path(path).expanduser(), reversed(args.config)):
657+
if config_file.is_file():
658+
config_files.append(config_file)
665659
else:
666660
# Only load first available default config
667661
for config_file in filter(lambda path: path.is_file(), CONFIG_FILES):
662+
if type(config_file) is DeprecatedPath:
663+
log.info(f"Loaded config from deprecated path, see CLI docs for how to migrate: {config_file}")
668664
config_files.append(config_file)
669665
break
670666

667+
if streamlink and args.url:
668+
# Only load first available plugin config
669+
with ignored(NoPluginError):
670+
plugin = streamlink.resolve_url(args.url)
671+
for config_file in CONFIG_FILES:
672+
config_file = config_file.with_name(f"{config_file.name}.{plugin.module}")
673+
if not config_file.is_file():
674+
continue
675+
if type(config_file) is DeprecatedPath:
676+
log.info(f"Loaded plugin config from deprecated path, see CLI docs for how to migrate: {config_file}")
677+
config_files.append(config_file)
678+
break
679+
671680
if config_files:
672681
setup_args(parser, config_files, ignore_unknown=ignore_unknown)
673682

0 commit comments

Comments
 (0)