From c038e3a4f0666dee87b2d8f68590218d4d2c0fc9 Mon Sep 17 00:00:00 2001 From: mBaratta96 Date: Mon, 7 Aug 2023 00:10:37 +0200 Subject: [PATCH] key for cache --- letterboxd_stats/web_scraper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/letterboxd_stats/web_scraper.py b/letterboxd_stats/web_scraper.py index 40095ca..b95e8ec 100644 --- a/letterboxd_stats/web_scraper.py +++ b/letterboxd_stats/web_scraper.py @@ -113,12 +113,13 @@ def _get_tmdb_id_from_web(link: str, is_diary: bool): def get_tmdb_id(link: str, is_diary=False): tmdb_id_cache = shelve.open(cache_path, writeback=False, protocol=5) - if link in tmdb_id_cache: - id = tmdb_id_cache[link] + key = link.split("/")[-1] + if key in tmdb_id_cache: + id = tmdb_id_cache[key] else: try: id = _get_tmdb_id_from_web(link, is_diary) - tmdb_id_cache[link] = id + tmdb_id_cache[key] = id except ValueError as e: print(e) id = None