- edit caching method
- misc edits.
This commit is contained in:
doms9 2026-04-01 20:23:29 -04:00
parent b4dc04ad58
commit 00000d90e4
4 changed files with 82 additions and 66 deletions

View file

@ -79,9 +79,11 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
async def scrape(browser: Browser) -> 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")
@ -108,29 +110,33 @@ async def scrape(browser: Browser) -> None:
log=log,
)
sport, event, ts = (
ev["sport"],
ev["event"],
ev["timestamp"],
)
tvg_id, logo = leagues.get_tvg_info(sport, event)
key = f"[{sport}] {event} ({TAG})"
entry = {
"url": url,
"logo": logo,
"base": "https://vividmosaica.com/",
"timestamp": ts,
"id": tvg_id or "Live.Event.us",
"link": link,
}
cached_urls[key] = entry
if url:
sport, event, ts = (
ev["sport"],
ev["event"],
ev["timestamp"],
)
valid_count += 1
tvg_id, logo = leagues.get_tvg_info(sport, event)
urls[key] = entry
key = f"[{sport}] {event} ({TAG})"
entry = {
"url": url,
"logo": logo,
"base": "https://vividmosaica.com/",
"timestamp": ts,
"id": tvg_id or "Live.Event.us",
"link": link,
}
urls[key] = cached_urls[key] = entry
log.info(f"Collected and cached {len(cached_urls) - cached_count} new event(s)")
log.info(f"Collected and cached {valid_count - cached_count} new event(s)")
else:
log.info("No new events found")