]> jfr.im git - yt-dlp.git/commitdiff
Make nested --config-locations relative to parent file
authorpukkandan <redacted>
Thu, 3 Feb 2022 12:48:18 +0000 (18:18 +0530)
committerpukkandan <redacted>
Thu, 3 Feb 2022 15:30:36 +0000 (21:00 +0530)
* and allow environment variables in it so that you can use `$PWD`/`%cd%`
to specify paths relative to current directory

yt_dlp/utils.py

index 8ba0c2d6cd3302f98427b03039cf176a08be5c9c..13ad5fd4899618425c9365cab84608b75b619791 100644 (file)
@@ -5222,8 +5222,10 @@ def __init__(self, parser, label=None):
 
     def init(self, args=None, filename=None):
         assert not self.__initialized
+        directory = ''
         if filename:
             location = os.path.realpath(filename)
+            directory = os.path.dirname(location)
             if location in self._loaded_paths:
                 return False
             self._loaded_paths.add(location)
@@ -5231,7 +5233,7 @@ def init(self, args=None, filename=None):
         self.__initialized = True
         self.own_args, self.filename = args, filename
         for location in self._parser.parse_args(args)[0].config_locations or []:
-            location = compat_expanduser(location)
+            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):