fix scraper crashing if api url(s) do not work
misc. edits
This commit is contained in:
doms9 2025-12-29 09:57:40 -05:00
parent 51598ce2a2
commit 00000d903e
9 changed files with 18 additions and 24 deletions

View file

@ -28,19 +28,19 @@ BASE_MIRRORS = [
async def get_events(api_url: str, cached_keys: list[str]) -> list[dict[str, str]]:
events = []
now = Time.clean(Time.now())
if not (api_data := API_FILE.load(per_entry=False)):
log.info("Refreshing API cache")
api_data = {}
api_data = {"timestamp": now.timestamp()}
if r := await network.request(api_url, log=log):
api_data: dict = r.json()
API_FILE.write(api_data)
now = Time.clean(Time.now())
events = []
start_dt = now.delta(minutes=-30)
end_dt = now.delta(minutes=30)