e
This commit is contained in:
parent
a979f0bf75
commit
00000d97a5
8 changed files with 40 additions and 29 deletions
|
|
@ -39,7 +39,9 @@ def fix_sport(s: str) -> str:
|
|||
async def refresh_api_cache(
|
||||
client: httpx.AsyncClient,
|
||||
url: str,
|
||||
ts: float,
|
||||
) -> list[dict[str, Any]]:
|
||||
|
||||
log.info("Refreshing API cache")
|
||||
|
||||
try:
|
||||
|
|
@ -52,7 +54,7 @@ async def refresh_api_cache(
|
|||
|
||||
data = r.json()
|
||||
|
||||
data[-1]["timestamp"] = Time.now().timestamp()
|
||||
data[-1]["timestamp"] = ts
|
||||
|
||||
return data
|
||||
|
||||
|
|
@ -126,16 +128,19 @@ async def get_events(
|
|||
cached_keys: set[str],
|
||||
) -> list[dict[str, str]]:
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
if not (api_data := API_FILE.load(per_entry=False, index=-1)):
|
||||
api_data = await refresh_api_cache(
|
||||
client, urljoin(url, "api/matches/all-today")
|
||||
client,
|
||||
urljoin(url, "api/matches/all-today"),
|
||||
now.timestamp(),
|
||||
)
|
||||
|
||||
API_FILE.write(api_data)
|
||||
|
||||
events = []
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
start_dt = now.delta(minutes=-30)
|
||||
end_dt = now.delta(minutes=30)
|
||||
pattern = re.compile(r"[\n\r]+|\s{2,}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue