mirror of
https://github.com/doms9/iptv.git
synced 2026-04-24 20:16:59 +02:00
Compare commits
31 commits
4f593f2460
...
cdc1ab64ab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdc1ab64ab | ||
|
|
281f13d054 | ||
|
|
aac3499893 | ||
|
|
6c11df91c2 | ||
|
|
195664f733 | ||
|
|
3fc149acf1 | ||
|
|
993077f8ef | ||
|
|
9291ab07be | ||
|
|
9af728029a | ||
|
|
ba553dd948 | ||
|
|
760d778acc | ||
|
|
f27a493375 | ||
|
|
05381b67e6 | ||
|
|
46e5f22bc0 | ||
|
|
e3f367e009 | ||
|
|
d7588e1349 | ||
|
|
82b2eb34a0 | ||
|
|
e51895a457 | ||
|
|
748ce43678 | ||
|
|
fa02883914 | ||
|
|
d67dd92e2d | ||
|
|
8528f8249f | ||
|
|
1cc2ac8107 | ||
|
|
71c0d7babf | ||
|
|
b858ff07c9 | ||
|
|
0e03fe51df | ||
|
|
2c8fbeb3ea | ||
|
|
91d426bd4c | ||
|
|
162ff8500a | ||
|
|
a4bea07c4b | ||
|
|
a9e2f84a33 |
6 changed files with 117013 additions and 115244 deletions
2890
M3U8/TV.m3u8
2890
M3U8/TV.m3u8
File diff suppressed because it is too large
Load diff
226204
M3U8/TV.xml
226204
M3U8/TV.xml
File diff suppressed because one or more lines are too long
2848
M3U8/events.m3u8
2848
M3U8/events.m3u8
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,6 @@ from scrapers import (
|
||||||
totalsportek3,
|
totalsportek3,
|
||||||
tvapp,
|
tvapp,
|
||||||
volokit,
|
volokit,
|
||||||
watchfooty,
|
|
||||||
webcast,
|
webcast,
|
||||||
)
|
)
|
||||||
from scrapers.utils import get_logger, network
|
from scrapers.utils import get_logger, network
|
||||||
|
|
@ -69,9 +68,9 @@ async def main() -> None:
|
||||||
asyncio.create_task(roxie.scrape(hdl_brwsr)),
|
asyncio.create_task(roxie.scrape(hdl_brwsr)),
|
||||||
asyncio.create_task(sportzone.scrape(xtrnl_brwsr)),
|
asyncio.create_task(sportzone.scrape(xtrnl_brwsr)),
|
||||||
asyncio.create_task(streamcenter.scrape(hdl_brwsr)),
|
asyncio.create_task(streamcenter.scrape(hdl_brwsr)),
|
||||||
# asyncio.create_task(streamhub.scrape(xtrnl_brwsr)),
|
asyncio.create_task(streamhub.scrape(xtrnl_brwsr)),
|
||||||
asyncio.create_task(streamsgate.scrape(xtrnl_brwsr)),
|
asyncio.create_task(streamsgate.scrape(xtrnl_brwsr)),
|
||||||
asyncio.create_task(timstreams.scrape(xtrnl_brwsr)),
|
# asyncio.create_task(timstreams.scrape(xtrnl_brwsr)),
|
||||||
]
|
]
|
||||||
|
|
||||||
httpx_tasks = [
|
httpx_tasks = [
|
||||||
|
|
@ -91,7 +90,6 @@ async def main() -> None:
|
||||||
await asyncio.gather(*(pw_tasks + httpx_tasks))
|
await asyncio.gather(*(pw_tasks + httpx_tasks))
|
||||||
|
|
||||||
# others
|
# others
|
||||||
# await watchfooty.scrape(xtrnl_brwsr)
|
|
||||||
await livetvsx.scrape(xtrnl_brwsr)
|
await livetvsx.scrape(xtrnl_brwsr)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
@ -122,7 +120,6 @@ async def main() -> None:
|
||||||
| totalsportek3.urls
|
| totalsportek3.urls
|
||||||
| tvapp.urls
|
| tvapp.urls
|
||||||
| volokit.urls
|
| volokit.urls
|
||||||
| watchfooty.urls
|
|
||||||
| webcast.urls
|
| webcast.urls
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,296 +0,0 @@
|
||||||
import asyncio
|
|
||||||
import re
|
|
||||||
from functools import partial
|
|
||||||
from itertools import chain
|
|
||||||
from typing import Any
|
|
||||||
from urllib.parse import urljoin
|
|
||||||
|
|
||||||
from playwright.async_api import Browser, Page, Response, TimeoutError
|
|
||||||
|
|
||||||
from .utils import Cache, Time, get_logger, leagues, network
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
|
||||||
|
|
||||||
urls: dict[str, dict[str, str | float]] = {}
|
|
||||||
|
|
||||||
TAG = "WATCHFTY"
|
|
||||||
|
|
||||||
CACHE_FILE = Cache(TAG, exp=10_800)
|
|
||||||
|
|
||||||
API_FILE = Cache(f"{TAG}-api", exp=19_800)
|
|
||||||
|
|
||||||
BASE_DOMAIN = "watchfooty.pw"
|
|
||||||
|
|
||||||
API_URL, BASE_URL = f"https://api.{BASE_DOMAIN}", f"https://www.{BASE_DOMAIN}"
|
|
||||||
|
|
||||||
VALID_SPORTS = [
|
|
||||||
# "american-football",
|
|
||||||
"baseball",
|
|
||||||
"basketball",
|
|
||||||
"fighting",
|
|
||||||
"football",
|
|
||||||
"golf",
|
|
||||||
"hockey",
|
|
||||||
"racing",
|
|
||||||
"tennis",
|
|
||||||
"volleyball",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
async def refresh_api_cache(now: Time) -> list[dict[str, Any]]:
|
|
||||||
tasks = [
|
|
||||||
network.request(
|
|
||||||
urljoin(API_URL, "api/v1/matches/all"),
|
|
||||||
log=log,
|
|
||||||
params={"date": d.date()},
|
|
||||||
)
|
|
||||||
for d in [now, now.delta(days=1)]
|
|
||||||
]
|
|
||||||
|
|
||||||
results = await asyncio.gather(*tasks)
|
|
||||||
|
|
||||||
if not (data := [*chain.from_iterable(r.json() for r in results if r)]):
|
|
||||||
return [{"timestamp": now.timestamp()}]
|
|
||||||
|
|
||||||
for ev in data:
|
|
||||||
ev["ts"] = ev.pop("timestamp")
|
|
||||||
|
|
||||||
data[-1]["timestamp"] = now.timestamp()
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def sift_xhr(resp: Response, match_id: int) -> bool:
|
|
||||||
resp_url = resp.url
|
|
||||||
|
|
||||||
return (
|
|
||||||
f"/en/stream/{match_id}/" in resp_url
|
|
||||||
and "_rsc=" not in resp_url
|
|
||||||
and resp.status == 200
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def process_event(
|
|
||||||
url: str,
|
|
||||||
match_id: int,
|
|
||||||
url_num: int,
|
|
||||||
page: Page,
|
|
||||||
) -> tuple[str | None, str | None]:
|
|
||||||
|
|
||||||
nones = None, None
|
|
||||||
|
|
||||||
captured: list[str] = []
|
|
||||||
|
|
||||||
got_one = asyncio.Event()
|
|
||||||
|
|
||||||
handler = partial(
|
|
||||||
network.capture_req,
|
|
||||||
captured=captured,
|
|
||||||
got_one=got_one,
|
|
||||||
)
|
|
||||||
|
|
||||||
strm_handler = partial(sift_xhr, match_id=match_id)
|
|
||||||
|
|
||||||
page.on("request", handler)
|
|
||||||
|
|
||||||
try:
|
|
||||||
try:
|
|
||||||
async with page.expect_response(strm_handler, timeout=3_250) as strm_resp:
|
|
||||||
resp = await page.goto(
|
|
||||||
url,
|
|
||||||
wait_until="domcontentloaded",
|
|
||||||
timeout=6_000,
|
|
||||||
)
|
|
||||||
|
|
||||||
if not resp or resp.status != 200:
|
|
||||||
log.warning(
|
|
||||||
f"URL {url_num}) Status Code: {resp.status if resp else 'None'}"
|
|
||||||
)
|
|
||||||
|
|
||||||
return nones
|
|
||||||
|
|
||||||
response = await strm_resp.value
|
|
||||||
|
|
||||||
stream_url = response.url
|
|
||||||
except TimeoutError:
|
|
||||||
log.warning(f"URL {url_num}) No available stream links.")
|
|
||||||
|
|
||||||
return nones
|
|
||||||
|
|
||||||
embed = re.sub(
|
|
||||||
pattern=r"^.*\/stream",
|
|
||||||
repl="https://pikachusports.top/embed",
|
|
||||||
string=stream_url,
|
|
||||||
)
|
|
||||||
|
|
||||||
await page.goto(
|
|
||||||
embed,
|
|
||||||
wait_until="domcontentloaded",
|
|
||||||
timeout=5_000,
|
|
||||||
)
|
|
||||||
|
|
||||||
wait_task = asyncio.create_task(got_one.wait())
|
|
||||||
|
|
||||||
try:
|
|
||||||
await asyncio.wait_for(wait_task, timeout=6)
|
|
||||||
except asyncio.TimeoutError:
|
|
||||||
log.warning(f"URL {url_num}) Timed out waiting for M3U8.")
|
|
||||||
|
|
||||||
return nones
|
|
||||||
|
|
||||||
finally:
|
|
||||||
if not wait_task.done():
|
|
||||||
wait_task.cancel()
|
|
||||||
|
|
||||||
try:
|
|
||||||
await wait_task
|
|
||||||
except asyncio.CancelledError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if captured:
|
|
||||||
log.info(f"URL {url_num}) Captured M3U8")
|
|
||||||
|
|
||||||
return captured[0], embed
|
|
||||||
|
|
||||||
log.warning(f"URL {url_num}) No M3U8 captured after waiting.")
|
|
||||||
|
|
||||||
return nones
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
log.warning(f"URL {url_num}) {e}")
|
|
||||||
|
|
||||||
return nones
|
|
||||||
|
|
||||||
finally:
|
|
||||||
page.remove_listener("request", handler)
|
|
||||||
|
|
||||||
|
|
||||||
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, index=-1)):
|
|
||||||
log.info("Refreshing API cache")
|
|
||||||
|
|
||||||
api_data = await refresh_api_cache(now)
|
|
||||||
|
|
||||||
API_FILE.write(api_data)
|
|
||||||
|
|
||||||
events = []
|
|
||||||
|
|
||||||
pattern = re.compile(r"\-+|\(")
|
|
||||||
|
|
||||||
start_dt = now.delta(minutes=-30)
|
|
||||||
end_dt = now.delta(minutes=5)
|
|
||||||
|
|
||||||
for event in api_data:
|
|
||||||
match_id = event.get("matchId")
|
|
||||||
|
|
||||||
name = event.get("title")
|
|
||||||
|
|
||||||
league = event.get("league")
|
|
||||||
|
|
||||||
if not (match_id and name and league):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if event["sport"] not in VALID_SPORTS:
|
|
||||||
continue
|
|
||||||
|
|
||||||
sport = pattern.split(league, 1)[0].strip()
|
|
||||||
|
|
||||||
if f"[{sport}] {name} ({TAG})" in cached_keys:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not (date := event.get("date")):
|
|
||||||
continue
|
|
||||||
|
|
||||||
event_dt = Time.from_str(date, timezone="UTC")
|
|
||||||
|
|
||||||
if not start_dt <= event_dt <= end_dt:
|
|
||||||
continue
|
|
||||||
|
|
||||||
logo = urljoin(API_URL, poster) if (poster := event.get("poster")) else None
|
|
||||||
|
|
||||||
events.append(
|
|
||||||
{
|
|
||||||
"sport": sport,
|
|
||||||
"event": name,
|
|
||||||
"link": urljoin(BASE_URL, f"stream/{match_id}"),
|
|
||||||
"match-id": match_id,
|
|
||||||
"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(
|
|
||||||
process_event,
|
|
||||||
url=(link := ev["link"]),
|
|
||||||
match_id=ev["match-id"],
|
|
||||||
url_num=i,
|
|
||||||
page=page,
|
|
||||||
)
|
|
||||||
|
|
||||||
url, iframe = await network.safe_process(
|
|
||||||
handler,
|
|
||||||
url_num=i,
|
|
||||||
semaphore=network.PW_S,
|
|
||||||
log=log,
|
|
||||||
timeout=20,
|
|
||||||
)
|
|
||||||
|
|
||||||
sport, event, logo, ts = (
|
|
||||||
ev["sport"],
|
|
||||||
ev["event"],
|
|
||||||
ev["logo"],
|
|
||||||
ev["timestamp"],
|
|
||||||
)
|
|
||||||
|
|
||||||
key = f"[{sport}] {event} ({TAG})"
|
|
||||||
|
|
||||||
tvg_id, pic = leagues.get_tvg_info(sport, event)
|
|
||||||
|
|
||||||
entry = {
|
|
||||||
"url": url,
|
|
||||||
"logo": logo or pic,
|
|
||||||
"base": iframe,
|
|
||||||
"timestamp": ts,
|
|
||||||
"id": tvg_id or "Live.Event.us",
|
|
||||||
"link": link,
|
|
||||||
}
|
|
||||||
|
|
||||||
cached_urls[key] = entry
|
|
||||||
|
|
||||||
if url:
|
|
||||||
valid_count += 1
|
|
||||||
|
|
||||||
entry["url"] = url.split("&t")[0]
|
|
||||||
|
|
||||||
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)
|
|
||||||
12
readme.md
12
readme.md
|
|
@ -1,13 +1,17 @@
|
||||||
## Base Log @ 2026-03-14 08:59 UTC
|
## Base Log @ 2026-03-15 09:00 UTC
|
||||||
|
|
||||||
### ✅ Working Streams: 157<br>❌ Dead Streams: 4
|
### ✅ Working Streams: 153<br>❌ Dead Streams: 8
|
||||||
|
|
||||||
| Channel | Error (Code) | Link |
|
| Channel | Error (Code) | Link |
|
||||||
| ------- | ------------ | ---- |
|
| ------- | ------------ | ---- |
|
||||||
| Altitude Sports | HTTP Error (403) | `http://mytvstream.net:8080/live/30550113/30550113/79545.m3u8` |
|
| Altitude Sports | HTTP Error (403) | `http://mytvstream.net:8080/live/30550113/30550113/79545.m3u8` |
|
||||||
| FDSN Southeast | HTTP Error (000) | `http://mytvstream.net:8080/live/30550113/30550113/2213.m3u8` |
|
| CBS Sports Network | HTTP Error (403) | `http://snowbank.houseinventer.com/7007/index.m3u8?token=c0lTeGc1M0gydFNjcloydGZhbTFsY1RYMkphdG5OcXdxNHpMeGFYWW5ZRERxNEduaVp1UnBxU2VlWmF0ZnRlRGxaMm1zNStDbnJOOXFZMlhtcStybmc9PQ==` |
|
||||||
|
| ESPN | HTTP Error (403) | `http://snowbank.houseinventer.com/6500/index.m3u8?token=M1lDdWljYkdyZGFhZzVxeGc2Mkt5OGJicWNxd2xheDkzWWVieEt5b3lZVERxNEduaVp1UnBxU2VlWmF0ZnRlRGxaMm1zNStDbnJOOXFZMlhtcStybmc9PQ==` |
|
||||||
|
| ESPN2 | HTTP Error (403) | `http://snowbank.houseinventer.com/6501/index.m3u8?token=M1lDdWljYkdyZGFhZzVxeGc2Mkt5OGJicWNxd2xheDkzWWVieEt5b3lZVERxNEduaVp1UnBxU2VlWmF0ZnRlRGxaMm1zNStDbnJOOXFZMlhtcStybmc9PQ==` |
|
||||||
|
| Game Show Network | HTTP Error (403) | `http://mytvstream.net:8080/live/30550113/30550113/120633.m3u8` |
|
||||||
|
| Hallmark Family | HTTP Error (403) | `http://mytvstream.net:8080/live/30550113/30550113/9307.m3u8` |
|
||||||
|
| NBC Sports California | HTTP Error (403) | `http://mytvstream.net:8080/live/30550113/30550113/20940.m3u8` |
|
||||||
| NHL Network | HTTP Error (000) | `http://mytvstream.net:8080/live/30550113/30550113/20179.m3u8` |
|
| NHL Network | HTTP Error (000) | `http://mytvstream.net:8080/live/30550113/30550113/20179.m3u8` |
|
||||||
| Spectrum SportsNet LA Dodgers | HTTP Error (403) | `http://mytvstream.net:8080/live/30550113/30550113/31636.m3u8` |
|
|
||||||
---
|
---
|
||||||
#### Base Channels URL
|
#### Base Channels URL
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue