]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/cache.py
[compat] Fix `compat.WINDOWS_VT_MODE`
[yt-dlp.git] / yt_dlp / cache.py
index 0cac3ee888edb8a3a61463eac870372f8922c421..e3f8a7dab2ff2e8e7ffe2f3071471f5dc011c739 100644 (file)
@@ -1,3 +1,4 @@
+import contextlib
 import errno
 import json
 import os
@@ -57,7 +58,7 @@ def load(self, section, key, dtype='json', default=None):
             return default
 
         cache_fn = self._get_cache_fn(section, key, dtype)
-        try:
+        with contextlib.suppress(OSError):
             try:
                 with open(cache_fn, encoding='utf-8') as cachef:
                     self._ydl.write_debug(f'Loading {section}.{key} from cache')
@@ -68,8 +69,6 @@ def load(self, section, key, dtype='json', default=None):
                 except OSError as oe:
                     file_size = str(oe)
                 self._ydl.report_warning(f'Cache retrieval from {cache_fn} failed ({file_size})')
-        except OSError:
-            pass  # No cache available
 
         return default