@@ -633,12 +633,9 @@ def setup_args(parser: argparse.ArgumentParser, config_files: List[Path] = None,
633
633
arglist = sys .argv [1 :]
634
634
635
635
# 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 []]
640
637
641
- args , unknown = parser .parse_known_args (arglist )
638
+ args , unknown = parser .parse_known_args (configs + arglist )
642
639
if unknown and not ignore_unknown :
643
640
msg = gettext ('unrecognized arguments: %s' )
644
641
parser .error (msg % ' ' .join (unknown ))
@@ -654,20 +651,32 @@ def setup_args(parser: argparse.ArgumentParser, config_files: List[Path] = None,
654
651
def setup_config_args (parser , ignore_unknown = False ):
655
652
config_files = []
656
653
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
-
662
654
if args .config :
663
655
# 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 )
665
659
else :
666
660
# Only load first available default config
667
661
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 } " )
668
664
config_files .append (config_file )
669
665
break
670
666
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
+
671
680
if config_files :
672
681
setup_args (parser , config_files , ignore_unknown = ignore_unknown )
673
682
0 commit comments