aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-02-03 18:18:18 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-02-03 21:00:36 +0530
commit65662dffb175d18b8b1de1d27f3b89a8a4a88b6b (patch)
tree5eccaeec243111d10098eac6b59a24adffe8d09b /yt_dlp/utils.py
parent5e51f4a8ad25aab0f78000d8812f4f1af490953e (diff)
downloadhypervideo-pre-65662dffb175d18b8b1de1d27f3b89a8a4a88b6b.tar.lz
hypervideo-pre-65662dffb175d18b8b1de1d27f3b89a8a4a88b6b.tar.xz
hypervideo-pre-65662dffb175d18b8b1de1d27f3b89a8a4a88b6b.zip
Make nested --config-locations relative to parent file
* and allow environment variables in it so that you can use `$PWD`/`%cd%` to specify paths relative to current directory
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 8ba0c2d6c..13ad5fd48 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -5222,8 +5222,10 @@ class Config:
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 @@ class Config:
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):