diff options
author | lauren n. liberda <lauren@selfisekai.rocks> | 2022-12-27 20:57:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-28 01:27:26 +0530 |
commit | da8d2de2082ab55f11d76d0aef7e6c3614672b45 (patch) | |
tree | 4da87773d8551a74840693b2cf36ca2f12afcd6a /yt_dlp/cache.py | |
parent | 15e9e578c04f1fa3f408dc3ec99491cc3f0ba839 (diff) |
[extractor/cda] Support premium and misc improvements (#5529)
* Fix cache for non-ASCII key
* Improve error messages
* Better UA for fingerprint bypass
Authored by: selfisekai
Diffstat (limited to 'yt_dlp/cache.py')
-rw-r--r-- | yt_dlp/cache.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/yt_dlp/cache.py b/yt_dlp/cache.py index 4f9fb78d3..7be91eae5 100644 --- a/yt_dlp/cache.py +++ b/yt_dlp/cache.py @@ -5,6 +5,7 @@ import os import re import shutil import traceback +import urllib.parse from .utils import expand_path, traverse_obj, version_tuple, write_json_file from .version import __version__ @@ -22,11 +23,9 @@ class Cache: return expand_path(res) def _get_cache_fn(self, section, key, dtype): - assert re.match(r'^[a-zA-Z0-9_.-]+$', section), \ - 'invalid section %r' % section - assert re.match(r'^[a-zA-Z0-9_.-]+$', key), 'invalid key %r' % key - return os.path.join( - self._get_root_dir(), section, f'{key}.{dtype}') + assert re.match(r'^[\w.-]+$', section), f'invalid section {section!r}' + key = urllib.parse.quote(key, safe='').replace('%', ',') # encode non-ascii characters + return os.path.join(self._get_root_dir(), section, f'{key}.{dtype}') @property def enabled(self): |