mirror of
https://github.com/doms9/iptv.git
synced 2026-03-07 11:18:25 +01:00
e
This commit is contained in:
parent
00000d9ab1
commit
00000d9604
5 changed files with 11 additions and 13 deletions
|
|
@ -3,7 +3,7 @@ import re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import feedparser
|
import feedparser
|
||||||
from playwright.async_api import Browser, Page
|
from playwright.async_api import Browser, Page, TimeoutError
|
||||||
|
|
||||||
from .utils import Cache, Time, get_logger, leagues, network
|
from .utils import Cache, Time, get_logger, leagues, network
|
||||||
|
|
||||||
|
|
@ -47,6 +47,8 @@ async def process_event(
|
||||||
page: Page,
|
page: Page,
|
||||||
) -> str | None:
|
) -> str | None:
|
||||||
|
|
||||||
|
event_id_pattern = re.compile(r"&c=(\d*)", re.I)
|
||||||
|
|
||||||
captured: list[str] = []
|
captured: list[str] = []
|
||||||
|
|
||||||
got_one = asyncio.Event()
|
got_one = asyncio.Event()
|
||||||
|
|
@ -57,8 +59,6 @@ async def process_event(
|
||||||
got_one=got_one,
|
got_one=got_one,
|
||||||
)
|
)
|
||||||
|
|
||||||
event_id_pattern = re.compile(r"&c=(\d*)", re.I)
|
|
||||||
|
|
||||||
page.on("request", handler)
|
page.on("request", handler)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -69,23 +69,21 @@ async def process_event(
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
log.warning(f"URL {url_num}) status code: {resp.status}")
|
log.warning(f"URL {url_num}) Status Code: {resp.status}")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
event_a = page.locator('a[title*="Aliez"]').first
|
event_a = page.locator('a[title*="Aliez"]').first
|
||||||
|
|
||||||
href = await event_a.get_attribute("href", timeout=1_250)
|
href = await event_a.get_attribute("href", timeout=1_250)
|
||||||
|
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
log.warning(f"URL {url_num}) No valid sources found.")
|
log.warning(f"URL {url_num}) No valid sources found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if match := event_id_pattern.search(href):
|
if (match := event_id_pattern.search(href)) and (
|
||||||
event_id = match[1]
|
event_id := match[1]
|
||||||
|
).isalnum():
|
||||||
event_url = f"https://emb.apl392.me/player/live.php?id={event_id}"
|
event_url = f"https://emb.apl392.me/player/live.php?id={event_id}"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
event_url = href if href.startswith("http") else f"https:{href}"
|
event_url = href if href.startswith("http") else f"https:{href}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ async def get_api_data(page: Page) -> dict[str, list[dict, str, str]]:
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
log.warning(f"{url} status code: {resp.status}")
|
log.warning(f"{url} Status Code: {resp.status}")
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ async def process_event(
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
log.warning(f"URL {url_num}) status code: {resp.status}")
|
log.warning(f"URL {url_num}) Status Code: {resp.status}")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ class Network:
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
log.warning(f"URL {url_num}) status code: {resp.status}")
|
log.warning(f"URL {url_num}) Status Code: {resp.status}")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ async def process_event(
|
||||||
)
|
)
|
||||||
|
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
log.warning(f"URL {url_num}) status code: {resp.status}")
|
log.warning(f"URL {url_num}) Status Code: {resp.status}")
|
||||||
return
|
return
|
||||||
|
|
||||||
await page.wait_for_timeout(2_000)
|
await page.wait_for_timeout(2_000)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue