e
This commit is contained in:
parent
795d9a1c17
commit
00000d93ef
3 changed files with 15 additions and 7 deletions
|
|
@ -269,12 +269,13 @@ async def main(client: httpx.AsyncClient) -> None:
|
|||
|
||||
cached_urls = load_cache(CACHE_FILE, exp=14400)
|
||||
cached_count = len(cached_urls)
|
||||
urls.update(cached_urls)
|
||||
|
||||
log.info(f"Collected {cached_count} event(s) from cache")
|
||||
|
||||
events = await get_events(BASE_URL, cert, set(cached_urls.keys()))
|
||||
|
||||
log.info(f"Processing {len(events)} new URLs")
|
||||
log.info(f"Processing {len(events)} new URL(s)")
|
||||
|
||||
for i, ev in enumerate(events, start=1):
|
||||
sport = ev["sport"]
|
||||
|
|
@ -302,6 +303,9 @@ async def main(client: httpx.AsyncClient) -> None:
|
|||
|
||||
urls[key] = cached_urls[key] = entry
|
||||
|
||||
CACHE_FILE.write_text(json.dumps(cached_urls, indent=2), encoding="utf-8")
|
||||
if (new_count := len(cached_urls) - cached_count) > 0:
|
||||
CACHE_FILE.write_text(json.dumps(cached_urls, indent=2), encoding="utf-8")
|
||||
|
||||
log.info(f"Collected {len(cached_urls) - cached_count} new event(s)")
|
||||
log.info(f"Collected and cached {new_count} new event(s)")
|
||||
else:
|
||||
log.info("No new events found")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue