fix hanging if no available mirrors
This commit is contained in:
doms9 2025-12-12 10:46:56 -05:00
parent 3a1d2742f1
commit 00000d9233
8 changed files with 24 additions and 16 deletions

View file

@ -38,7 +38,7 @@ def fix_sport(s: str) -> str:
async def refresh_api_cache(
client: httpx.AsyncClient,
url: str,
ts: float,
now_ts: float,
) -> list[dict[str, Any]]:
log.info("Refreshing API cache")
@ -49,11 +49,12 @@ async def refresh_api_cache(
except Exception as e:
log.error(f'Failed to fetch "{url}": {e}')
return {}
return []
data = r.json()
if not (data := r.json()):
return []
data[-1]["timestamp"] = ts
data[-1]["timestamp"] = now_ts
return data