- edit scraping for streamhub.py
- edit scraping for streamsgate.py
- misc edits.
This commit is contained in:
doms9 2026-04-05 17:26:17 -04:00
parent 55c8b7cfd3
commit 00000d9788
3 changed files with 171 additions and 102 deletions

View file

@ -27,36 +27,26 @@ def fix_txt(s: str) -> str:
async def process_event(url: str, url_num: int) -> str | None:
if not (event_data := await network.request(url, log=log)):
log.warning(f"URL {url_num}) Failed to load url.")
return
soup_1 = HTMLParser(event_data.content)
if not (iframe_1 := soup_1.css_first("iframe")):
iframe_1 = soup_1.css_first("iframe")
if not iframe_1 or not (iframe_1_src := iframe_1.attributes.get("src")):
log.warning(f"URL {url_num}) No iframe element found. (IFR1)")
return
if not (iframe_1_src := iframe_1.attributes.get("src")):
log.warning(f"URL {url_num}) No iframe source found. (IFR1)")
return
if not (iframe_1_src_data := await network.request(iframe_1_src, log=log)):
log.warning(f"URL {url_num}) Failed to load iframe source. (IFR1)")
return
soup_2 = HTMLParser(iframe_1_src_data.content)
if not (iframe_2 := soup_2.css_first("iframe")):
iframe_2 = soup_2.css_first("iframe")
if not iframe_2 or not (iframe_2_src := iframe_2.attributes.get("src")):
log.warning(f"URL {url_num}) No iframe element found. (IFR2)")
return
if not (iframe_2_src := iframe_2.attributes.get("src")):
log.warning(f"URL {url_num}) No iframe source found. (IFR2)")
return
if not (
@ -67,14 +57,12 @@ async def process_event(url: str, url_num: int) -> str | None:
)
):
log.warning(f"URL {url_num}) Failed to load iframe source. (IFR2)")
return
valid_m3u8 = re.compile(r'currentStreamUrl\s+=\s+"([^"]*)"', re.I)
if not (match := valid_m3u8.search(iframe_2_src_data.text)):
log.warning(f"URL {url_num}) No Clappr source found. (IFR2)")
log.warning(f"URL {url_num}) No Clappr source found.")
return
log.info(f"URL {url_num}) Captured M3U8")