diff options
author | Mark Oteiza <mvoteiza@udel.edu> | 2013-09-29 22:50:46 -0400 |
---|---|---|
committer | Mark Oteiza <mvoteiza@udel.edu> | 2013-09-30 18:22:38 -0400 |
commit | fa556755930db77c62016a468d870e76608db012 (patch) | |
tree | d2c59e16fb87ef2ad31bb50c64ee19c18cff46f0 /youtube_dl/extractor | |
parent | 722076a123c60ed6d5a978c4bc2609f46c8e3ee9 (diff) |
Support XDG base directory specification
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/youtube.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 53f13b516..23e384ba2 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -420,8 +420,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor): # Read from filesystem cache func_id = '%s_%s_%d' % (player_type, player_id, slen) assert os.path.basename(func_id) == func_id - cache_dir = self._downloader.params.get('cachedir', - u'~/.youtube-dl/cache') + xdg_cache_home = os.environ.get('XDG_CACHE_HOME') + if xdg_cache_home: + userCacheDir = os.path.join(xdg_cache_home, 'youtube-dl') + else: + userCacheDir = os.path.join(os.path.expanduser('~'), '.cache', 'youtube-dl') + cache_dir = self._downloader.params.get('cachedir', userCacheDir) cache_enabled = cache_dir is not None if cache_enabled: |