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: async def scrape() -> None:
cached_urls = CACHE_FILE.load() 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") log.info(f"Loaded {cached_count} event(s) from cache")
@ -137,29 +139,33 @@ async def scrape() -> None:
log=log, 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: if url:
sport, event, link = ( valid_count += 1
ev["sport"],
ev["event"],
ev["link"],
)
key = f"[{sport}] {event} ({TAG})" urls[key] = entry
tvg_id, logo = leagues.get_tvg_info(sport, event) if new_count := valid_count - cached_count:
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:
log.info(f"Collected and cached {new_count} new event(s)") log.info(f"Collected and cached {new_count} new event(s)")
else: else:

View file

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