From 00000d927ffb9264a7522c8fdae3f486160ec8c7 Mon Sep 17 00:00:00 2001 From: doms9 <96013514+doms9@users.noreply.github.com> Date: Thu, 11 Jun 2026 15:07:40 -0400 Subject: [PATCH] e - misc edits. --- M3U8/scrapers/pelotalibre.py | 3 +++ M3U8/scrapers/streamsgate.py | 8 ++++++-- M3U8/scrapers/streamtp.py | 38 ++++++++++++------------------------ 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/M3U8/scrapers/pelotalibre.py b/M3U8/scrapers/pelotalibre.py index a2cec1b7..3db9409c 100644 --- a/M3U8/scrapers/pelotalibre.py +++ b/M3U8/scrapers/pelotalibre.py @@ -43,6 +43,9 @@ async def get_events() -> list[dict[str, str]]: if not (name := event.get("title")) or not (link := event.get("link")): continue + elif "drm.php" in link: + continue + if (sport := event.get("category")) and sport == "Other": sport = "Live Event" diff --git a/M3U8/scrapers/streamsgate.py b/M3U8/scrapers/streamsgate.py index 6c5797ec..8c968cbf 100644 --- a/M3U8/scrapers/streamsgate.py +++ b/M3U8/scrapers/streamsgate.py @@ -1,4 +1,5 @@ import asyncio +import json import re from functools import partial from itertools import chain @@ -71,7 +72,10 @@ async def process_event(url: str, url_num: int) -> tuple[str | None, str | None] log.warning(f"URL {url_num}) Failed to load iframe source. (IFR1)") return nones - valid_m3u8 = re.compile(r"(file|source):\s+(\'|\")([^\"]*)(\'|\")", re.I) + valid_m3u8 = re.compile( + r"(file|source|currentStreamUrl)\s*(:|=)\s+(\'|\")([^\"]*)(\'|\")", + re.I, + ) if not (match := valid_m3u8.search(ifr_src_data.text)): log.warning(f"URL {url_num}) No source found.") @@ -79,7 +83,7 @@ async def process_event(url: str, url_num: int) -> tuple[str | None, str | None] log.info(f"URL {url_num}) Captured M3U8") - return match[3], ifr_src + return json.loads(f'"{match[4]}"'), ifr_src async def get_events() -> list[dict[str, str]]: diff --git a/M3U8/scrapers/streamtp.py b/M3U8/scrapers/streamtp.py index 2a59d8c0..e53779b9 100644 --- a/M3U8/scrapers/streamtp.py +++ b/M3U8/scrapers/streamtp.py @@ -1,5 +1,4 @@ -import ast -import base64 +import json import re from functools import partial @@ -13,41 +12,25 @@ TAG = "STP" CACHE_FILE = Cache(TAG, exp=19_800) -API_URL = "https://streamtp-x-y-z.ws/eventos.json" +API_URL = "https://streamtpday1.xyz/eventos.json" async def process_event(url: str, url_num: int) -> str | None: - if not (event_data := await network.request(url, log=log)): + if not (html_data := await network.request(url, log=log)): log.warning(f"URL {url_num}) Failed to load url.") return - digit_func_ptrn = re.compile(r"{return\s+(\d*);}", re.I) + valid_m3u8 = re.compile(r'var\s+playbackURL\s+=\s+"([^"]*)"', re.I) - if not (digit_list := digit_func_ptrn.findall(event_data.text)): - log.warning(f"URL {url_num}) Unable to decode url.") + if not (match := valid_m3u8.search(html_data.text)): + log.warning(f"URL {url_num}) No M3U8 found") return - embed_list_ptrn = re.compile(r"\w*=\[\[(.*)\]\];") - - if not (embed_list := embed_list_ptrn.search(event_data.text)): - log.warning(f"URL {url_num}) Unable to decode url.") - return - - embed_list_str = embed_list[0].split("=", 1)[-1].strip(";") - - embed_list: list[tuple[int, str]] = ast.literal_eval(embed_list_str) - - m3u8 = "".join( - chr( - int("".join(c for c in base64.b64decode(v).decode("utf-8") if c.isdigit())) - - sum(map(int, digit_list)) - ) - for _, v in sorted(embed_list, key=lambda i: i[0]) - ) - log.info(f"URL {url_num}) Captured M3U8") - return m3u8.split("ip=")[0] + m3u8 = match[1].split("ip=")[0] + + return json.loads(f'"{m3u8}"') async def get_events() -> list[dict[str, str]]: @@ -63,6 +46,9 @@ async def get_events() -> list[dict[str, str]]: if not (name := event.get("title")) or not (link := event.get("link")): continue + elif "sudamericaplay" in link: + continue + if (sport := event.get("category")) and sport == "Other": sport = "Live Event"