From 00000d9b811d9a184f73d47059e3f3b2a15898cb Mon Sep 17 00:00:00 2001 From: doms9 <96013514+doms9@users.noreply.github.com> Date: Sun, 12 Oct 2025 00:27:42 -0400 Subject: [PATCH] e --- M3U8/scrapers/fstv.py | 2 ++ M3U8/scrapers/livetvsx.py | 2 ++ M3U8/scrapers/streambtw.py | 1 + M3U8/scrapers/streamed.py | 1 + M3U8/scrapers/strmd.py | 1 + M3U8/scrapers/utils/caching.py | 1 + M3U8/scrapers/utils/config.py | 21 ++++++++++++++++++--- M3U8/scrapers/utils/webwork.py | 1 + M3U8/scrapers/watchfooty.py | 8 +++----- 9 files changed, 30 insertions(+), 8 deletions(-) diff --git a/M3U8/scrapers/fstv.py b/M3U8/scrapers/fstv.py index d79dbee..c7cb041 100644 --- a/M3U8/scrapers/fstv.py +++ b/M3U8/scrapers/fstv.py @@ -25,6 +25,7 @@ async def get_events( base_url: str, cached_hrefs: set[str], ) -> list[dict[str, str]]: + log.info(f'Scraping from "{base_url}"') try: @@ -80,6 +81,7 @@ async def process_event( url: str, url_num: int, ) -> tuple[str, str]: + try: r = await client.get(url) r.raise_for_status() diff --git a/M3U8/scrapers/livetvsx.py b/M3U8/scrapers/livetvsx.py index d0cd9c9..264047f 100644 --- a/M3U8/scrapers/livetvsx.py +++ b/M3U8/scrapers/livetvsx.py @@ -34,6 +34,7 @@ async def write_to_cert( url: str, cert: Path, ) -> None: + try: r = await client.get(url) r.raise_for_status() @@ -94,6 +95,7 @@ async def process_event( url_num: int, context: BrowserContext, ) -> str | None: + page = await context.new_page() captured: list[str] = [] diff --git a/M3U8/scrapers/streambtw.py b/M3U8/scrapers/streambtw.py index 37085b9..e8c28aa 100644 --- a/M3U8/scrapers/streambtw.py +++ b/M3U8/scrapers/streambtw.py @@ -21,6 +21,7 @@ async def process_event( url: str, url_num: int, ) -> str | None: + try: r = await client.get(url) r.raise_for_status() diff --git a/M3U8/scrapers/streamed.py b/M3U8/scrapers/streamed.py index 5d3fa94..cce17ac 100644 --- a/M3U8/scrapers/streamed.py +++ b/M3U8/scrapers/streamed.py @@ -25,6 +25,7 @@ async def process_event( url_num: int, context: BrowserContext, ) -> str | None: + page = await context.new_page() captured: list[str] = [] diff --git a/M3U8/scrapers/strmd.py b/M3U8/scrapers/strmd.py index 331cd90..87dfe72 100644 --- a/M3U8/scrapers/strmd.py +++ b/M3U8/scrapers/strmd.py @@ -55,6 +55,7 @@ async def process_event( url_num: int, context: BrowserContext, ) -> str | None: + page = await context.new_page() captured: list[str] = [] diff --git a/M3U8/scrapers/utils/caching.py b/M3U8/scrapers/utils/caching.py index e80fb3a..cc2c68f 100644 --- a/M3U8/scrapers/utils/caching.py +++ b/M3U8/scrapers/utils/caching.py @@ -22,6 +22,7 @@ class Cache: per_entry: bool = True, index: bool = False, ) -> dict[str, dict[str, str | float]]: + try: data: dict = json.loads(self.file.read_text(encoding="utf-8")) except (FileNotFoundError, json.JSONDecodeError): diff --git a/M3U8/scrapers/utils/config.py b/M3U8/scrapers/utils/config.py index 74eb434..551db9e 100644 --- a/M3U8/scrapers/utils/config.py +++ b/M3U8/scrapers/utils/config.py @@ -35,7 +35,12 @@ class Time(datetime): return self.__class__.fromtimestamp(dt.timestamp(), tz=ZONES[tzone]) @classmethod - def from_str(cls, s: str, fmt: str | None = None) -> "Time": + def from_str( + cls, + s: str, + fmt: str | None = None, + ) -> "Time": + pattern = re.compile(r"\b(ET|UTC|EST|EDT)\b") match = pattern.search(s) @@ -99,7 +104,12 @@ class Leagues: return (None, self.live_img) - def is_valid(self, event: str, league: str) -> bool: + def is_valid( + self, + event: str, + league: str, + ) -> bool: + pattern = re.compile(r"\s+(?:-|vs\.?|at)\s+", flags=re.IGNORECASE) if pattern.search(event): @@ -109,7 +119,12 @@ class Leagues: return event.lower() == "nfl redzone" if league == "NFL" else False - def get_tvg_info(self, sport: str, event: str) -> tuple[str | None, str]: + def get_tvg_info( + self, + sport: str, + event: str, + ) -> tuple[str | None, str]: + match sport: case "American Football": return ( diff --git a/M3U8/scrapers/utils/webwork.py b/M3U8/scrapers/utils/webwork.py index 540144e..3f19413 100644 --- a/M3U8/scrapers/utils/webwork.py +++ b/M3U8/scrapers/utils/webwork.py @@ -84,6 +84,7 @@ class Network: got_one: asyncio.Event, patterns: list[str] | None = None, ) -> None: + if not patterns: patterns = ["amazonaws", "knitcdn"] diff --git a/M3U8/scrapers/watchfooty.py b/M3U8/scrapers/watchfooty.py index 2a492e0..9a2543c 100644 --- a/M3U8/scrapers/watchfooty.py +++ b/M3U8/scrapers/watchfooty.py @@ -36,10 +36,7 @@ SPORT_ENDPOINTS = [ ] -async def get_api_data( - client: httpx.AsyncClient, - url: str, -) -> list[dict[str, Any]]: +async def get_api_data(client: httpx.AsyncClient, url: str) -> list[dict[str, Any]]: try: r = await client.get(url, timeout=10) r.raise_for_status() @@ -137,6 +134,7 @@ async def process_event( await iframe.click("button.vds-play-button") except TimeoutError: log.warning("Play button not found inside iframe.") + return wait_task = asyncio.create_task(got_one.wait()) @@ -218,7 +216,7 @@ async def get_events( { "sport": sport, "event": name, - "link": f"https://www.watchfooty.live/en/stream/{match_id}", + "link": urljoin(base_url, f"stream/{match_id}"), "logo": logo, "timestamp": event_dt.timestamp(), }