This commit is contained in:
doms9 2025-09-13 13:32:32 -04:00
parent 21f39fb5a0
commit 00000d9000
7 changed files with 37 additions and 44 deletions

View file

@ -41,23 +41,24 @@ async def get_events(
events = []
for wrpr in soup.css("div.fixtures-live-wrapper"):
for games in wrpr.css(".match-table-item"):
for league_block in wrpr.css(".match-table-item > .league-info-wrapper"):
if not (
league_name_el := league_block.css_first(".league-info a.league-name")
):
continue
league_name = games.css_first(".league-info a.league-name")
full_text = league_name_el.text(strip=True)
league_match = games.css_first(".common-table-row a[href*='/match/']")
if "]" in full_text:
event_name = full_text.split("]", 1)[1].strip()
else:
event_name = full_text
if league_name and league_match:
full_text = league_name.text(strip=True)
parent_item = league_block.parent
if "]" in full_text:
event_name = full_text.split("]", 1)[1].strip()
else:
event_name = full_text
href = league_match.attributes.get("href")
link = urljoin(base_url, href)
for game in parent_item.css(".common-table-row a[href*='/match/']"):
if not (href := game.attributes.get("href")):
continue
if cached_hrefs & {href}:
continue
@ -65,11 +66,8 @@ async def get_events(
events.append(
{
"sport": event_name,
"link": link,
"logo": LOGOS.get(
event_name,
"https://i.gyazo.com/ec27417a9644ae517196494afa72d2b9.png",
),
"link": urljoin(base_url, href),
"logo": LOGOS.get(event_name, LOGOS["default"]),
"href": href,
}
)
@ -103,13 +101,13 @@ async def process_event(
og_title.attributes.get("content", "").split(" start on")[0].strip()
)
if ifr := soup.css_first("iframe"):
if src := ifr.attributes.get("src", ""):
log.info(f"URL {url_num}) Captured M3U8")
return match_name, unquote(src).split("link=")[-1]
if not (ifr := soup.css_first("iframe")):
log.info(f"URL {url_num}) No M3U8 found")
return "", ""
log.info(f"URL {url_num}) No M3U8 found")
return "", ""
if src := ifr.attributes.get("src", ""):
log.info(f"URL {url_num}) Captured M3U8")
return match_name, unquote(src).split("link=")[-1]
async def main(client: httpx.AsyncClient) -> None: