mirror of
https://github.com/doms9/iptv.git
synced 2026-04-21 19:46:59 +02:00
update M3U8
This commit is contained in:
parent
6fcef2ca09
commit
b7f67772f8
5 changed files with 507 additions and 1496 deletions
838
M3U8/TV.m3u8
838
M3U8/TV.m3u8
File diff suppressed because it is too large
Load diff
838
M3U8/events.m3u8
838
M3U8/events.m3u8
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,7 @@ from scrapers import (
|
|||
fawa,
|
||||
istreameast,
|
||||
livetvsx,
|
||||
ovogoal,
|
||||
pawa,
|
||||
ppv,
|
||||
roxie,
|
||||
|
|
@ -17,7 +18,6 @@ from scrapers import (
|
|||
streamcenter,
|
||||
streamhub,
|
||||
streamsgate,
|
||||
timstreams,
|
||||
totalsportek,
|
||||
tvapp,
|
||||
watchfooty,
|
||||
|
|
@ -65,12 +65,12 @@ async def main() -> None:
|
|||
asyncio.create_task(streamcenter.scrape(hdl_brwsr)),
|
||||
# asyncio.create_task(streamhub.scrape(xtrnl_brwsr)),
|
||||
asyncio.create_task(streamsgate.scrape(xtrnl_brwsr)),
|
||||
# asyncio.create_task(timstreams.scrape(xtrnl_brwsr)),
|
||||
]
|
||||
|
||||
httpx_tasks = [
|
||||
asyncio.create_task(fawa.scrape()),
|
||||
asyncio.create_task(istreameast.scrape()),
|
||||
asyncio.create_task(ovogoal.scrape()),
|
||||
asyncio.create_task(pawa.scrape()),
|
||||
asyncio.create_task(shark.scrape()),
|
||||
asyncio.create_task(totalsportek.scrape()),
|
||||
|
|
@ -97,6 +97,7 @@ async def main() -> None:
|
|||
| fawa.urls
|
||||
| istreameast.urls
|
||||
| livetvsx.urls
|
||||
| ovogoal.urls
|
||||
| pawa.urls
|
||||
| ppv.urls
|
||||
| roxie.urls
|
||||
|
|
@ -104,7 +105,6 @@ async def main() -> None:
|
|||
| streamcenter.urls
|
||||
| streamhub.urls
|
||||
| streamsgate.urls
|
||||
| timstreams.urls
|
||||
| totalsportek.urls
|
||||
| tvapp.urls
|
||||
| watchfooty.urls
|
||||
|
|
|
|||
152
M3U8/scrapers/ovogoal.py
Normal file
152
M3U8/scrapers/ovogoal.py
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
import re
|
||||
from functools import partial
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from selectolax.parser import HTMLParser
|
||||
|
||||
from .utils import Cache, Time, get_logger, leagues, network
|
||||
|
||||
log = get_logger(__name__)
|
||||
|
||||
urls: dict[str, dict[str, str | float]] = {}
|
||||
|
||||
TAG = "OVOGOAL"
|
||||
|
||||
CACHE_FILE = Cache(TAG, exp=28_800)
|
||||
|
||||
BASE_URL = "https://ovogoal.plus"
|
||||
|
||||
|
||||
async def process_event(url: str, url_num: int) -> tuple[str | None, str | None]:
|
||||
nones = None, None
|
||||
|
||||
if not (html_data := await network.request(url, log=log)):
|
||||
log.warning(f"URL {url_num}) Failed to load url.")
|
||||
return nones
|
||||
|
||||
soup = HTMLParser(html_data.content)
|
||||
|
||||
iframe = soup.css_first("iframe")
|
||||
|
||||
if not iframe or not (iframe_src := iframe.attributes.get("src")):
|
||||
log.warning(f"URL {url_num}) No iframe element found.")
|
||||
return nones
|
||||
|
||||
if not (
|
||||
iframe_src_data := await network.request(
|
||||
iframe_src,
|
||||
headers={"Referer": url},
|
||||
log=log,
|
||||
)
|
||||
):
|
||||
log.warning(f"URL {url_num}) Failed to load iframe source.")
|
||||
return nones
|
||||
|
||||
valid_m3u8 = re.compile(r'(var|const)\s+(\w+)\s*=\s*"([^"]*)"', re.I)
|
||||
|
||||
if not (match := valid_m3u8.search(iframe_src_data.text)):
|
||||
log.warning(f"URL {url_num}) No Clappr source found.")
|
||||
return nones
|
||||
|
||||
log.info(f"URL {url_num}) Captured M3U8")
|
||||
|
||||
return match[3], iframe_src
|
||||
|
||||
|
||||
async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
|
||||
events = []
|
||||
|
||||
if not (html_data := await network.request(BASE_URL, log=log)):
|
||||
return events
|
||||
|
||||
soup = HTMLParser(html_data.content)
|
||||
|
||||
sport = "Live Event"
|
||||
|
||||
for card in soup.css(".main-content .stream-row"):
|
||||
if (not (watch_btn_elem := card.css_first(".watch-btn"))) or (
|
||||
not (onclick := watch_btn_elem.attributes.get("onclick"))
|
||||
):
|
||||
continue
|
||||
|
||||
if not (event_name_elem := card.css_first(".stream-info")):
|
||||
continue
|
||||
|
||||
href = onclick.split(".href=")[-1].replace("'", "")
|
||||
|
||||
event_name = event_name_elem.text(strip=True)
|
||||
|
||||
if f"[{sport}] {event_name} ({TAG})" in cached_keys:
|
||||
continue
|
||||
|
||||
events.append(
|
||||
{
|
||||
"sport": sport,
|
||||
"event": event_name,
|
||||
"link": urljoin(BASE_URL, href),
|
||||
}
|
||||
)
|
||||
|
||||
return events
|
||||
|
||||
|
||||
async def scrape() -> None:
|
||||
cached_urls = CACHE_FILE.load()
|
||||
|
||||
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
|
||||
|
||||
valid_count = cached_count = len(valid_urls)
|
||||
|
||||
urls.update(valid_urls)
|
||||
|
||||
log.info(f"Loaded {cached_count} event(s) from cache")
|
||||
|
||||
log.info(f'Scraping from "{BASE_URL}"')
|
||||
|
||||
if events := await get_events(cached_urls.keys()):
|
||||
log.info(f"Processing {len(events)} new URL(s)")
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
for i, ev in enumerate(events, start=1):
|
||||
handler = partial(
|
||||
process_event,
|
||||
url=(link := ev["link"]),
|
||||
url_num=i,
|
||||
)
|
||||
|
||||
url, iframe = await network.safe_process(
|
||||
handler,
|
||||
url_num=i,
|
||||
semaphore=network.HTTP_S,
|
||||
log=log,
|
||||
)
|
||||
|
||||
sport, event = ev["sport"], ev["event"]
|
||||
|
||||
key = f"[{sport}] {event} ({TAG})"
|
||||
|
||||
tvg_id, logo = leagues.get_tvg_info(sport, event)
|
||||
|
||||
entry = {
|
||||
"url": url,
|
||||
"logo": logo,
|
||||
"base": iframe,
|
||||
"timestamp": now.timestamp(),
|
||||
"id": tvg_id or "Live.Event.us",
|
||||
"link": link,
|
||||
}
|
||||
|
||||
cached_urls[key] = entry
|
||||
|
||||
if url:
|
||||
valid_count += 1
|
||||
|
||||
urls[key] = entry
|
||||
|
||||
log.info(f"Collected and cached {valid_count - cached_count} new event(s)")
|
||||
|
||||
else:
|
||||
log.info("No new events found")
|
||||
|
||||
CACHE_FILE.write(cached_urls)
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
from functools import partial
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from playwright.async_api import Browser
|
||||
|
||||
from .utils import Cache, Time, get_logger, leagues, network
|
||||
|
||||
log = get_logger(__name__)
|
||||
|
||||
urls: dict[str, dict[str, str | float]] = {}
|
||||
|
||||
TAG = "TIMSTRMS"
|
||||
|
||||
CACHE_FILE = Cache(TAG, exp=3_600)
|
||||
|
||||
API_FILE = Cache(f"{TAG}-api", exp=19_800)
|
||||
|
||||
API_URL = "https://timstreams.fit/api/live-upcoming"
|
||||
|
||||
BASE_URL = "https://timstreams.fit"
|
||||
|
||||
SPORT_GENRES = {
|
||||
1: "Soccer",
|
||||
2: "Motorsport",
|
||||
3: "MMA",
|
||||
4: "Fight",
|
||||
5: "Boxing",
|
||||
6: "Wrestling",
|
||||
7: "Basketball",
|
||||
# 8: "American Football",
|
||||
9: "Baseball",
|
||||
10: "Tennis",
|
||||
11: "Hockey",
|
||||
# 12: "Darts",
|
||||
# 13: "Cricket",
|
||||
# 14: "Cycling",
|
||||
# 15: "Rugby",
|
||||
# 16: "Live Shows",
|
||||
# 17: "Other",
|
||||
}
|
||||
|
||||
|
||||
async def get_events(cached_keys: list[str]) -> list[dict[str, str]]:
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
if not (api_data := API_FILE.load(per_entry=False)):
|
||||
log.info("Refreshing API cache")
|
||||
|
||||
api_data = {"timestamp": now.timestamp()}
|
||||
|
||||
if r := await network.request(API_URL, log=log):
|
||||
api_data: dict = r.json()
|
||||
|
||||
api_data["timestamp"] = now.timestamp()
|
||||
|
||||
API_FILE.write(api_data)
|
||||
|
||||
events = []
|
||||
|
||||
start_dt = now.delta(hours=-3)
|
||||
end_dt = now.delta(minutes=5)
|
||||
|
||||
for info in api_data.get("events", []):
|
||||
if (genre := info.get("genre", 999)) not in SPORT_GENRES:
|
||||
continue
|
||||
|
||||
event_time = " ".join(info["time"].split("T"))
|
||||
|
||||
event_dt = Time.from_str(event_time, timezone="EST")
|
||||
|
||||
if not start_dt <= event_dt <= end_dt:
|
||||
continue
|
||||
|
||||
name: str = info["name"]
|
||||
|
||||
url_id: str = info["url"]
|
||||
|
||||
logo: str | None = info.get("logo")
|
||||
|
||||
sport = SPORT_GENRES[genre]
|
||||
|
||||
if f"[{sport}] {name} ({TAG})" in cached_keys:
|
||||
continue
|
||||
|
||||
if not (streams := info.get("streams")) or not (url := streams[0].get("url")):
|
||||
continue
|
||||
|
||||
events.append(
|
||||
{
|
||||
"sport": sport,
|
||||
"event": name,
|
||||
"link": urljoin(BASE_URL, f"watch/{url_id}"),
|
||||
"ref": url,
|
||||
"logo": logo,
|
||||
"timestamp": event_dt.timestamp(),
|
||||
}
|
||||
)
|
||||
|
||||
return events
|
||||
|
||||
|
||||
async def scrape(browser: Browser) -> None:
|
||||
cached_urls = CACHE_FILE.load()
|
||||
|
||||
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
|
||||
|
||||
valid_count = cached_count = len(valid_urls)
|
||||
|
||||
urls.update(valid_urls)
|
||||
|
||||
log.info(f"Loaded {cached_count} event(s) from cache")
|
||||
|
||||
log.info(f'Scraping from "{BASE_URL}"')
|
||||
|
||||
if events := await get_events(cached_urls.keys()):
|
||||
log.info(f"Processing {len(events)} new URL(s)")
|
||||
|
||||
async with network.event_context(browser, stealth=False) as context:
|
||||
for i, ev in enumerate(events, start=1):
|
||||
async with network.event_page(context) as page:
|
||||
handler = partial(
|
||||
network.process_event,
|
||||
url=(link := ev["link"]),
|
||||
url_num=i,
|
||||
page=page,
|
||||
log=log,
|
||||
)
|
||||
|
||||
url = await network.safe_process(
|
||||
handler,
|
||||
url_num=i,
|
||||
semaphore=network.PW_S,
|
||||
log=log,
|
||||
)
|
||||
|
||||
sport, event, logo, ref, ts = (
|
||||
ev["sport"],
|
||||
ev["event"],
|
||||
ev["logo"],
|
||||
ev["ref"],
|
||||
ev["timestamp"],
|
||||
)
|
||||
|
||||
key = f"[{sport}] {event} ({TAG})"
|
||||
|
||||
tvg_id, pic = leagues.get_tvg_info(sport, event)
|
||||
|
||||
entry = {
|
||||
"url": url,
|
||||
"logo": logo or pic,
|
||||
"base": ref,
|
||||
"timestamp": ts,
|
||||
"id": tvg_id or "Live.Event.us",
|
||||
"link": link,
|
||||
}
|
||||
|
||||
cached_urls[key] = entry
|
||||
|
||||
if url:
|
||||
valid_count += 1
|
||||
|
||||
urls[key] = entry
|
||||
|
||||
log.info(f"Collected and cached {valid_count - cached_count} new event(s)")
|
||||
|
||||
else:
|
||||
log.info("No new events found")
|
||||
|
||||
CACHE_FILE.write(cached_urls)
|
||||
Loading…
Add table
Add a link
Reference in a new issue