From 99fa53ecded801f39fab950b15c4728526a95ab8 Mon Sep 17 00:00:00 2001 From: Chaz Larson Date: Fri, 14 Oct 2022 16:49:17 -0500 Subject: [PATCH] enable requests-cache --- plex_meta_manager.py | 9 +++++++++ requirements.txt | 1 + 2 files changed, 10 insertions(+) diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 80a76953..95e78b04 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -3,6 +3,15 @@ from concurrent.futures import ProcessPoolExecutor from datetime import datetime from modules.logs import MyLogger +from requests_cache import install_cache +from datetime import datetime, timedelta +install_cache( + 'config/http_cache', + expire_after=timedelta(days=1), # Otherwise expire responses after one day + allowable_methods=['GET', 'POST'], # Cache POST requests to avoid sending the same data twice + allowable_codes=[200], + match_headers=True, +) try: import plexapi, requests, schedule from PIL import ImageFile diff --git a/requirements.txt b/requirements.txt index 6f4dbe91..692b6666 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ tmdbapis==1.0.6 arrapi==1.3.1 lxml==4.9.1 requests==2.28.1 +requests-cache==0.9.6 ruamel.yaml==0.17.21 schedule==1.1.0 retrying==1.3.3