From a4e4060d8d8f6b8ff9c9cd2ebc73ad5a9a39c263 Mon Sep 17 00:00:00 2001 From: Bernat Arlandis Date: Thu, 29 Jun 2023 20:05:13 +0200 Subject: [PATCH 1/2] Fix for newer requests-cache --- tvdb_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tvdb_api.py b/tvdb_api.py index 624abd2..bca9943 100644 --- a/tvdb_api.py +++ b/tvdb_api.py @@ -528,7 +528,7 @@ def __repr__(self): return "" % self.get("name") -def create_key(self, request): +def create_key(self, request, **kwargs): """A new cache_key algo is required as the authentication token changes with each run. Also there are other header params which also change with each request (e.g. timestamp). Excluding all @@ -544,7 +544,7 @@ def create_key(self, request): cache is to be used thus saving host and network traffic. """ - if self._ignored_parameters: + if self.ignored_parameters: url, body = self._remove_ignored_parameters(request) else: url, body = request.url, request.body @@ -554,7 +554,7 @@ def create_key(self, request): if request.body: key.update(_to_bytes(body)) else: - if self._include_get_headers and request.headers != _DEFAULT_HEADERS: + if self.match_headers and request.headers != _DEFAULT_HEADERS: for name, value in sorted(request.headers.items()): # include only Accept-Language as it is important for context if name in ['Accept-Language']: From 13d24b9cb60d5849fbf86b115c854868bb76913c Mon Sep 17 00:00:00 2001 From: Bernat Arlandis Date: Wed, 2 Aug 2023 18:10:39 +0200 Subject: [PATCH 2/2] Fix tests --- tests/test_tvdb_api.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_tvdb_api.py b/tests/test_tvdb_api.py index 2b3034f..e4a93de 100644 --- a/tests/test_tvdb_api.py +++ b/tests/test_tvdb_api.py @@ -103,14 +103,12 @@ def __init__(self, _name, fc_base_dir, **options): self.keys_map = FileCacheDict(base_dir=fc_base_dir) -requests_cache.backends.registry['tvdb_api_file_cache'] = FileCache - def get_test_cache_session(): here = os.path.dirname(os.path.abspath(__file__)) additional = "_py2" if sys.version_info[0] == 2 else "" sess = requests_cache.CachedSession( - backend="tvdb_api_file_cache", + backend="filesystem", fc_base_dir=os.path.join(here, "httpcache%s" % additional), include_get_headers=True, allowable_codes=(200, 404),