X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/1c1cff6a525bc8fc506cf2c6eb8963abc3b1fcee..97f34a48d72c5e55a584b7defc0dd00d2d9b416c:/youtube_dl/cache.py diff --git a/youtube_dl/cache.py b/youtube_dl/cache.py index 79ff09f78..7bdade1bd 100644 --- a/youtube_dl/cache.py +++ b/youtube_dl/cache.py @@ -8,7 +8,9 @@ import shutil import traceback +from .compat import compat_getenv from .utils import ( + expand_path, write_json_file, ) @@ -20,9 +22,9 @@ def __init__(self, ydl): def _get_root_dir(self): res = self._ydl.params.get('cachedir') if res is None: - cache_root = os.environ.get('XDG_CACHE_HOME', '~/.cache') + cache_root = compat_getenv('XDG_CACHE_HOME', '~/.cache') res = os.path.join(cache_root, 'youtube-dl') - return os.path.expanduser(res) + return expand_path(res) def _get_cache_fn(self, section, key, dtype): assert re.match(r'^[a-zA-Z0-9_.-]+$', section), \