This commit is contained in:
doms9 2026-04-05 12:29:27 -04:00
parent 75cc3e4bb5
commit 00000d917d

View file

@ -64,36 +64,34 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
soup = HTMLParser(html_data.content) soup = HTMLParser(html_data.content)
for card in soup.css(".section-title"): sport = None
sport = fix_league(card.text(strip=True))
node = card.next for node in soup.css(".wrapper *"):
if (cls := node.attributes.get("class")) == "section-title":
sport = fix_league(node.text(strip=True))
while node: if node.tag == "a" and cls == "match":
if node.attributes.get("class") == "section-title": if not sport:
break continue
elif node.tag == "a" and node.attributes.get("class") == "match": if not (team_elems := node.css(".team")):
if not (team_elems := node.css(".team")): continue
continue
if not (href := node.attributes.get("href")): if not (href := node.attributes.get("href")):
continue continue
event_name = " vs ".join(team.text(strip=True) for team in team_elems) event_name = " vs ".join(team.text(strip=True) for team in team_elems)
if f"[{sport}] {event_name} ({TAG})" in cached_keys: if f"[{sport}] {event_name} ({TAG})" in cached_keys:
continue continue
events.append( events.append(
{ {
"sport": sport, "sport": sport,
"event": event_name, "event": event_name,
"link": href, "link": href,
} }
) )
node = node.next
return events return events