This commit is contained in:
doms9 2025-11-13 12:43:55 -05:00
parent 4f6e1caa5f
commit 00000d9c6d
16 changed files with 106 additions and 89 deletions

View file

@ -1,5 +1,4 @@
from functools import partial
from pathlib import Path
from urllib.parse import urljoin
import httpx
@ -11,9 +10,9 @@ log = get_logger(__name__)
urls: dict[str, dict[str, str | float]] = {}
API_FILE = Cache(Path(__file__).parent / "caches" / "ppv_api.json", exp=28_800)
CACHE_FILE = Cache("ppv.json", exp=10_800)
CACHE_FILE = Cache(Path(__file__).parent / "caches" / "ppv.json", exp=10_800)
API_FILE = Cache("ppv-api.json", exp=28_800)
BASE_URL = "https://ppv.to"
@ -29,6 +28,7 @@ async def refresh_api_cache(
r.raise_for_status()
except Exception as e:
log.error(f'Failed to fetch "{url}": {e}')
return {}
return r.json()
@ -49,7 +49,7 @@ async def get_events(
API_FILE.write(api_data)
events: list[dict[str, str]] = []
events = []
now = Time.clean(Time.now())
start_dt = now.delta(minutes=-30)