This commit is contained in:
doms9 2026-04-14 20:55:38 -04:00
parent 00000d991c
commit 00000d92e4

View file

@ -2,6 +2,7 @@ import ast
import asyncio import asyncio
import re import re
from functools import partial from functools import partial
from urllib.parse import urljoin
from selectolax.parser import HTMLParser from selectolax.parser import HTMLParser
@ -26,7 +27,12 @@ def fix_event(s: str) -> str:
return " vs ".join(s.split("@")) return " vs ".join(s.split("@"))
async def process_event(url: str, url_num: int) -> str | None: async def process_event(
url: str,
url_num: int,
sport: str,
) -> str | None:
if not (event_data := await network.request(url, log=log)): if not (event_data := await network.request(url, log=log)):
log.warning(f"URL {url_num}) Failed to load url.") log.warning(f"URL {url_num}) Failed to load url.")
return return
@ -67,7 +73,7 @@ async def process_event(url: str, url_num: int) -> str | None:
if not ( if not (
api_data := await network.request( api_data := await network.request(
"https://mlbwebcast.com/stream/check_stream.php", urljoin(BASE_URLS[sport], "stream/check_stream.php"),
headers={"Referer": iframe_src}, headers={"Referer": iframe_src},
params=params, params=params,
log=log, log=log,
@ -153,6 +159,7 @@ async def scrape() -> None:
process_event, process_event,
url=(link := ev["link"]), url=(link := ev["link"]),
url_num=i, url_num=i,
sport=(sport := ev["sport"]),
) )
url = await network.safe_process( url = await network.safe_process(
@ -162,7 +169,7 @@ async def scrape() -> None:
log=log, log=log,
) )
sport, event = ev["sport"], ev["event"] event = ev["event"]
key = f"[{sport}] {event} ({TAG})" key = f"[{sport}] {event} ({TAG})"