- misc edits
This commit is contained in:
doms9 2026-04-26 17:48:36 -04:00
parent 3481d400f6
commit 00000d9df2
2 changed files with 18 additions and 10 deletions

View file

@ -1,5 +1,6 @@
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
@ -13,17 +14,19 @@ TAG = "LTVSX"
CACHE_FILE = Cache(TAG, exp=10_800) CACHE_FILE = Cache(TAG, exp=10_800)
BASE_URL = "https://livetv.sx/export/webmasters.php" BASE_URL = "https://livetv.sx"
async def process_event(url: str, url_num: int) -> tuple[str | None, str | None]: async def process_event(url: str, url_num: int) -> tuple[str | None, str | None]:
nones = None, None nones = None, None
if not (ev_data_1 := await network.request(url, log=log)): r = await network.unvd_client.get(url)
log.warning(f"URL {url_num}) Failed to load url. (EVD1)")
if r.status_code != 200:
log.warning(f"{url_num}) Failed to get event data.")
return nones return nones
soup_1 = HTMLParser(ev_data_1.content) soup_1 = HTMLParser(r.content)
for a_elem in soup_1.css("a"): for a_elem in soup_1.css("a"):
if not (src_title := a_elem.attributes.get("title")) or ( if not (src_title := a_elem.attributes.get("title")) or (
@ -40,11 +43,11 @@ async def process_event(url: str, url_num: int) -> tuple[str | None, str | None]
log.warning(f"URL {url_num}) No valid sources found.") log.warning(f"URL {url_num}) No valid sources found.")
return nones return nones
if not (ev_data_2 := await network.request(event_url, log=log)): if not (ev_data := await network.request(event_url, log=log)):
log.warning(f"URL {url_num}) Failed to load url. (EVD2)") log.warning(f"URL {url_num}) Failed to load url. (EVD2)")
return nones return nones
soup_2 = HTMLParser(ev_data_2.content) soup_2 = HTMLParser(ev_data.content)
ifr_1 = soup_2.css_first("tr > td > iframe") ifr_1 = soup_2.css_first("tr > td > iframe")
@ -76,13 +79,16 @@ async def process_event(url: str, url_num: int) -> tuple[str | None, str | None]
async def get_events(cached_keys: list[str]) -> list[dict[str, str]]: async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
events = [] events = []
php_data = await network.unvd_client.get(BASE_URL, params={"lang": "en"}) r = await network.unvd_client.get(
urljoin(BASE_URL, "export/webmasters.php"),
params={"lang": "en"},
)
if php_data.status_code != 200: if r.status_code != 200:
log.warning("Failed to get php data.") log.warning("Failed to get php data.")
return events return events
soup = HTMLParser(php_data.content) soup = HTMLParser(r.content)
if not (table := soup.css_first("table.tbl")): if not (table := soup.css_first("table.tbl")):
return events return events
@ -114,7 +120,7 @@ async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
"sport": sport, "sport": sport,
"league": league, "league": league,
"event": event_name, "event": event_name,
"link": f"https://cdn.livetv880.me/cache/links/en.{event_id[2:]}.html", "link": urljoin(BASE_URL, f"cache/links/en.{event_id[2:]}.html"),
} }
) )

View file

@ -45,6 +45,8 @@ async def process_event(url: str, url_num: int) -> str | None:
return f"https://mainstreams.pro/hls/{iframe_src.rsplit("=", 1)[-1]}.m3u8" return f"https://mainstreams.pro/hls/{iframe_src.rsplit("=", 1)[-1]}.m3u8"
# return f"https://edgestreams.pro/hls/{iframe_src.rsplit("=", 1)[-1]}.m3u8"
async def get_events() -> list[dict[str, str]]: async def get_events() -> list[dict[str, str]]:
events = [] events = []