e
This commit is contained in:
parent
b110aee1e8
commit
00000d9ba6
11 changed files with 121 additions and 135 deletions
|
|
@ -68,7 +68,7 @@ async def refresh_api_cache(
|
|||
for ev in data:
|
||||
ev["ts"] = ev.pop("timestamp")
|
||||
|
||||
data[0]["timestamp"] = Time.now().timestamp()
|
||||
data[-1]["timestamp"] = Time.now().timestamp()
|
||||
|
||||
return data
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ async def get_events(
|
|||
cached_keys: set[str],
|
||||
) -> list[dict[str, str]]:
|
||||
|
||||
if not (api_data := API_FILE.load(per_entry=False, index=True)):
|
||||
if not (api_data := API_FILE.load(per_entry=False, index=-1)):
|
||||
api_data = await refresh_api_cache(client, base_url)
|
||||
|
||||
API_FILE.write(api_data)
|
||||
|
|
@ -227,15 +227,9 @@ async def scrape(client: httpx.AsyncClient) -> None:
|
|||
browser, context = await network.browser(p)
|
||||
|
||||
for i, ev in enumerate(events, start=1):
|
||||
url = await network.safe_process(
|
||||
lambda: process_event(
|
||||
ev["link"],
|
||||
url_num=i,
|
||||
context=context,
|
||||
),
|
||||
url_num=i,
|
||||
log=log,
|
||||
)
|
||||
handler = partial(process_event, url=ev["link"], url_num=i, context=context)
|
||||
|
||||
url = await network.safe_process(handler, url_num=i, log=log)
|
||||
|
||||
sport, event, logo, ts = (
|
||||
ev["sport"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue