cache nulls from totalsportek
This commit is contained in:
doms9 2025-12-27 12:52:18 -05:00
parent 2240077021
commit 00000d9875
2 changed files with 29 additions and 22 deletions

View file

@ -108,9 +108,11 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
async def scrape() -> None:
cached_urls = CACHE_FILE.load()
cached_count = len(cached_urls)
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
urls.update(cached_urls)
valid_count = cached_count = len(valid_urls)
urls.update(valid_urls)
log.info(f"Loaded {cached_count} event(s) from cache")
@ -137,29 +139,33 @@ async def scrape() -> None:
log=log,
)
sport, event, link = (
ev["sport"],
ev["event"],
ev["link"],
)
key = f"[{sport}] {event} ({TAG})"
tvg_id, logo = leagues.get_tvg_info(sport, event)
entry = {
"url": url,
"logo": logo,
"base": iframe,
"timestamp": now.timestamp(),
"id": tvg_id or "Live.Event.us",
"link": link,
}
cached_urls[key] = entry
if url:
sport, event, link = (
ev["sport"],
ev["event"],
ev["link"],
)
valid_count += 1
key = f"[{sport}] {event} ({TAG})"
urls[key] = entry
tvg_id, logo = leagues.get_tvg_info(sport, event)
entry = {
"url": url,
"logo": logo,
"base": iframe,
"timestamp": now.timestamp(),
"id": tvg_id or "Live.Event.us",
"link": link,
}
urls[key] = cached_urls[key] = entry
if new_count := len(cached_urls) - cached_count:
if new_count := valid_count - cached_count:
log.info(f"Collected and cached {new_count} new event(s)")
else:

View file

@ -304,6 +304,7 @@ async def scrape() -> None:
if url:
valid_count += 1
urls[key] = entry
finally: