This commit is contained in:
doms9 2025-09-03 18:41:07 -04:00
parent 26eac184ee
commit 00000d96a5
3 changed files with 76 additions and 77 deletions

View file

@ -71,7 +71,6 @@ async def process_event(url: str, url_num: int) -> str | None:
".m3u8" in req.url
and "amazonaws" not in req.url
and "knitcdn" not in req.url
and not captured
):
captured.append(req.url)
got_one.set()
@ -119,12 +118,15 @@ async def process_event(url: str, url_num: int) -> str | None:
async def get_events(
client: httpx.AsyncClient,
api_url: str,
cached_keys: list[str],
cached_keys: set[str],
) -> dict[str, dict[str, str | str]]:
events = []
events: list[dict[str, str]] = []
base_url = re.match(r"(https?://.+?)/", api_url)[1]
now = datetime.now(TZ)
if not (api_data := load_api_cache()):
api_data = await refresh_api_cache(client, api_url)
API_FILE.write_text(json.dumps(api_data, indent=2), encoding="utf-8")
@ -156,7 +158,7 @@ async def get_events(
end_dt = datetime.fromtimestamp(end_ts, tz=TZ)
if not start_dt <= datetime.now(TZ) < end_dt:
if not start_dt <= now < end_dt:
continue
events.append(
@ -189,10 +191,10 @@ async def main(client: httpx.AsyncClient) -> None:
log.info(f"Processing {len(events)} URLs")
for num, ev in enumerate(events, start=1):
for i, ev in enumerate(events, start=1):
url = await safe_process_event(
lambda: process_event(ev["link"], url_num=num),
url_num=num,
lambda: process_event(ev["link"], url_num=i),
url_num=i,
log=log,
)
@ -212,7 +214,7 @@ async def main(client: httpx.AsyncClient) -> None:
log.info(f"Cached {cached_count} event(s)")
log.info(f"Collected {new_count} event(s)")
log.info(f"Collected {new_count} new event(s)")
# works if no cloudflare bot detection