mirror of
https://github.com/doms9/iptv.git
synced 2026-01-21 03:59:03 +01:00
Compare commits
36 commits
18d8258f33
...
00000d9ebc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00000d9ebc | ||
|
|
86a88e206e | ||
|
|
9ceaf58464 | ||
|
|
38d0b4789b | ||
|
|
1ed6ae2fa2 | ||
|
|
25099a00bc | ||
|
|
45b9e13357 | ||
|
|
c2176bfa6c | ||
|
|
290177daaa | ||
|
|
aaa01c8496 | ||
|
|
33129a8005 | ||
|
|
d846a24f62 | ||
|
|
6cc57b8353 | ||
|
|
7404d016da | ||
|
|
ed889f0c52 | ||
|
|
3cde03ff54 | ||
|
|
345f6df1d6 | ||
|
|
00000d9cc1 | ||
|
|
f755ffc78b | ||
|
|
91e4994c32 | ||
|
|
2f47e80d83 | ||
|
|
31f5671034 | ||
|
|
783953d797 | ||
|
|
a953d526df | ||
|
|
5302dccdac | ||
|
|
58d4140a2e | ||
|
|
6f5f9c45fd | ||
|
|
7fdcefb0c1 | ||
|
|
819b3f5f1f | ||
|
|
65a5e11448 | ||
|
|
19cb160712 | ||
|
|
d5f714251e | ||
|
|
69d67c467c | ||
|
|
3e1cac41c1 | ||
|
|
bb3600ede9 | ||
|
|
a1b593d216 |
12 changed files with 89623 additions and 91548 deletions
175318
EPG/TV.xml
175318
EPG/TV.xml
File diff suppressed because one or more lines are too long
2812
M3U8/TV.m3u8
2812
M3U8/TV.m3u8
File diff suppressed because it is too large
Load diff
2812
M3U8/events.m3u8
2812
M3U8/events.m3u8
File diff suppressed because it is too large
Load diff
|
|
@ -62,7 +62,7 @@ async def main() -> None:
|
|||
asyncio.create_task(streamhub.scrape(network.client)),
|
||||
asyncio.create_task(streamsgate.scrape(network.client)),
|
||||
asyncio.create_task(strmd.scrape(network.client)),
|
||||
# asyncio.create_task(timstreams.scrape(network.client)),
|
||||
asyncio.create_task(timstreams.scrape(network.client)),
|
||||
asyncio.create_task(tvpass.scrape(network.client)),
|
||||
asyncio.create_task(watchfooty.scrape(network.client)),
|
||||
asyncio.create_task(webcast.scrape(network.client)),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
from playwright.async_api import async_playwright
|
||||
|
||||
|
|
@ -49,8 +48,6 @@ async def get_events() -> dict[str, dict[str, str | float]]:
|
|||
|
||||
events = {}
|
||||
|
||||
pattern = re.compile(r"https?://[^\s'\"]+?\.m3u8(?:\?[^\s'\"]*)?", re.IGNORECASE)
|
||||
|
||||
for event in api_data.get("events", []):
|
||||
event_dt = Time.from_str(event["date"], timezone="UTC")
|
||||
|
||||
|
|
@ -66,8 +63,7 @@ async def get_events() -> dict[str, dict[str, str | float]]:
|
|||
stream_urls = [(i, f"server{i}URL") for i in range(1, 4)]
|
||||
|
||||
for z, stream_url in stream_urls:
|
||||
if stream_link := channel_info.get(stream_url):
|
||||
if pattern.search(stream_link):
|
||||
if (stream_link := channel_info.get(stream_url)) and stream_link != "null":
|
||||
key = f"[{sport}] {event_name} {z} ({TAG})"
|
||||
|
||||
tvg_id, logo = leagues.get_tvg_info(sport, event_name)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,18 @@ async def process_event(
|
|||
return match[1]
|
||||
|
||||
|
||||
async def get_html_data(client: httpx.AsyncClient, url: str) -> bytes:
|
||||
try:
|
||||
r = await client.get(url)
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{url}": {e}')
|
||||
|
||||
return b""
|
||||
|
||||
return r.content
|
||||
|
||||
|
||||
async def refresh_html_cache(
|
||||
client: httpx.AsyncClient,
|
||||
url: str,
|
||||
|
|
@ -64,15 +76,9 @@ async def refresh_html_cache(
|
|||
now_ts: float,
|
||||
) -> dict[str, dict[str, str | float]]:
|
||||
|
||||
try:
|
||||
r = await client.get(url)
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{url}": {e}')
|
||||
html_data = await get_html_data(client, url)
|
||||
|
||||
return {}
|
||||
|
||||
soup = HTMLParser(r.content)
|
||||
soup = HTMLParser(html_data)
|
||||
|
||||
events = {}
|
||||
|
||||
|
|
@ -108,16 +114,15 @@ async def refresh_html_cache(
|
|||
|
||||
|
||||
async def get_events(
|
||||
client: httpx.AsyncClient,
|
||||
sport_urls: dict[str, str],
|
||||
cached_keys: set[str],
|
||||
client: httpx.AsyncClient, cached_keys: set[str]
|
||||
) -> list[dict[str, str]]:
|
||||
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
if not (events := HTML_CACHE.load()):
|
||||
log.info("Refreshing HTML cache")
|
||||
|
||||
sport_urls = {sport: urljoin(BASE_URL, sport) for sport in SPORT_ENDPOINTS}
|
||||
|
||||
tasks = [
|
||||
refresh_html_cache(
|
||||
client,
|
||||
|
|
@ -160,13 +165,7 @@ async def scrape(client: httpx.AsyncClient) -> None:
|
|||
|
||||
log.info(f'Scraping from "{BASE_URL}"')
|
||||
|
||||
sport_urls = {sport: urljoin(BASE_URL, sport) for sport in SPORT_ENDPOINTS}
|
||||
|
||||
events = await get_events(
|
||||
client,
|
||||
sport_urls,
|
||||
set(cached_urls.keys()),
|
||||
)
|
||||
events = await get_events(client, set(cached_urls.keys()))
|
||||
|
||||
log.info(f"Processing {len(events)} new URL(s)")
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ async def process_event(
|
|||
async def refresh_html_cache(
|
||||
client: httpx.AsyncClient, now_ts: float
|
||||
) -> dict[str, dict[str, str | float]]:
|
||||
|
||||
log.info("Refreshing HTML cache")
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ async def get_html_data(
|
|||
r = await client.get(url, params={"date": date})
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{url}": {e}')
|
||||
log.error(f'Failed to fetch "{r.url}": {e}')
|
||||
|
||||
return b""
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ async def refresh_api_cache(
|
|||
r = await client.get(BASE_URL, params={"pageNumber": 1, "pageSize": 500})
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{BASE_URL}": {e}')
|
||||
log.error(f'Failed to fetch "{r.url}": {e}')
|
||||
|
||||
return []
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ BASE_URL = "https://streamfree.to/"
|
|||
|
||||
async def refresh_api_cache(client: httpx.AsyncClient) -> dict[str, dict[str, list]]:
|
||||
try:
|
||||
url = urljoin(BASE_URL, "streams")
|
||||
|
||||
r = await client.get(url)
|
||||
r = await client.get(urljoin(BASE_URL, "streams"))
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{url}": {e}')
|
||||
log.error(f'Failed to fetch "{r.url}": {e}')
|
||||
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import asyncio
|
||||
from functools import partial
|
||||
from urllib.parse import urljoin
|
||||
|
||||
import httpx
|
||||
from playwright.async_api import async_playwright
|
||||
|
|
@ -15,7 +16,9 @@ TAG = "STRMHUB"
|
|||
|
||||
CACHE_FILE = Cache(f"{TAG.lower()}.json", exp=10_800)
|
||||
|
||||
BASE_URL = "https://streamhub.pro/live-now"
|
||||
HTML_CACHE = Cache(f"{TAG.lower()}-html.json", exp=28_800)
|
||||
|
||||
BASE_URL = "https://streamhub.pro/"
|
||||
|
||||
|
||||
CATEGORIES = {
|
||||
|
|
@ -33,31 +36,40 @@ CATEGORIES = {
|
|||
}
|
||||
|
||||
|
||||
async def get_html_data(client: httpx.AsyncClient, sport: str) -> bytes:
|
||||
async def get_html_data(
|
||||
client: httpx.AsyncClient,
|
||||
date: str,
|
||||
sport_id: str,
|
||||
) -> bytes:
|
||||
|
||||
try:
|
||||
r = await client.get(BASE_URL, params={"sport_id": sport})
|
||||
r = await client.get(
|
||||
urljoin(BASE_URL, f"events/{date}"),
|
||||
params={"sport_id": sport_id},
|
||||
)
|
||||
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
log.error(f'Failed to fetch "{BASE_URL}": {e}')
|
||||
log.error(f'Failed to fetch "{r.url}": {e}')
|
||||
|
||||
return b""
|
||||
|
||||
return r.content
|
||||
|
||||
|
||||
async def get_events(
|
||||
client: httpx.AsyncClient, cached_keys: set[str]
|
||||
) -> list[dict[str, str]]:
|
||||
async def refresh_html_cache(
|
||||
client: httpx.AsyncClient,
|
||||
date: str,
|
||||
sport_id: str,
|
||||
ts: float,
|
||||
) -> dict[str, dict[str, str | float]]:
|
||||
|
||||
tasks = [get_html_data(client, sport) for sport in CATEGORIES.values()]
|
||||
html_data = await get_html_data(client, date, sport_id)
|
||||
|
||||
results = await asyncio.gather(*tasks)
|
||||
soup = HTMLParser(html_data)
|
||||
|
||||
soups = [HTMLParser(html) for html in results]
|
||||
events = {}
|
||||
|
||||
events = []
|
||||
|
||||
for soup in soups:
|
||||
for section in soup.css(".events-section"):
|
||||
if not (sport_node := section.css_first(".section-titlte")):
|
||||
continue
|
||||
|
|
@ -74,28 +86,76 @@ async def get_events(
|
|||
|
||||
event_name = f"{away} vs {home}"
|
||||
|
||||
if not (event_button := event.css_first("div.event-button a")) or not (
|
||||
if not (event_button := event.css_first(".event-button a")) or not (
|
||||
href := event_button.attributes.get("href")
|
||||
):
|
||||
continue
|
||||
|
||||
event_date = event.css_first(".event-countdown").attributes.get(
|
||||
"data-start"
|
||||
)
|
||||
|
||||
event_dt = Time.from_str(event_date, timezone="UTC")
|
||||
|
||||
key = f"[{sport}] {event_name} ({TAG})"
|
||||
|
||||
if cached_keys & {key}:
|
||||
continue
|
||||
|
||||
events.append(
|
||||
{
|
||||
events[key] = {
|
||||
"sport": sport,
|
||||
"event": event_name,
|
||||
"link": href,
|
||||
"logo": logo,
|
||||
"timestamp": ts,
|
||||
"event_ts": event_dt.timestamp(),
|
||||
}
|
||||
)
|
||||
|
||||
return events
|
||||
|
||||
|
||||
async def get_events(
|
||||
client: httpx.AsyncClient,
|
||||
cached_keys: set[str],
|
||||
) -> list[dict[str, str]]:
|
||||
now = Time.clean(Time.now())
|
||||
|
||||
if not (events := HTML_CACHE.load()):
|
||||
log.info("Refreshing HTML cache")
|
||||
|
||||
dates = [now.date(), now.delta(days=1).date()]
|
||||
|
||||
tasks = [
|
||||
refresh_html_cache(
|
||||
client,
|
||||
date,
|
||||
sport_id,
|
||||
now.timestamp(),
|
||||
)
|
||||
for date in dates
|
||||
for sport_id in CATEGORIES.values()
|
||||
]
|
||||
|
||||
results = await asyncio.gather(*tasks)
|
||||
|
||||
events = {k: v for data in results for k, v in data.items()}
|
||||
|
||||
HTML_CACHE.write(events)
|
||||
|
||||
live = []
|
||||
|
||||
start_ts = now.delta(hours=-1).timestamp()
|
||||
end_ts = now.delta(minutes=5).timestamp()
|
||||
|
||||
for k, v in events.items():
|
||||
if cached_keys & {k}:
|
||||
continue
|
||||
|
||||
if not start_ts <= v["event_ts"] <= end_ts:
|
||||
continue
|
||||
|
||||
live.append({**v})
|
||||
|
||||
return live
|
||||
|
||||
|
||||
async def scrape(client: httpx.AsyncClient) -> None:
|
||||
cached_urls = CACHE_FILE.load()
|
||||
valid_urls = {k: v for k, v in cached_urls.items() if v["url"]}
|
||||
|
|
@ -111,8 +171,6 @@ async def scrape(client: httpx.AsyncClient) -> None:
|
|||
log.info(f"Processing {len(events)} new URL(s)")
|
||||
|
||||
if events:
|
||||
now = Time.now().timestamp()
|
||||
|
||||
async with async_playwright() as p:
|
||||
browser, context = await network.browser(p)
|
||||
|
||||
|
|
@ -132,11 +190,12 @@ async def scrape(client: httpx.AsyncClient) -> None:
|
|||
log=log,
|
||||
)
|
||||
|
||||
sport, event, logo, link = (
|
||||
sport, event, logo, link, ts = (
|
||||
ev["sport"],
|
||||
ev["event"],
|
||||
ev["logo"],
|
||||
ev["link"],
|
||||
ev["event_ts"],
|
||||
)
|
||||
|
||||
key = f"[{sport}] {event} ({TAG})"
|
||||
|
|
@ -147,7 +206,7 @@ async def scrape(client: httpx.AsyncClient) -> None:
|
|||
"url": url,
|
||||
"logo": logo or pic,
|
||||
"base": "https://storytrench.net/",
|
||||
"timestamp": now,
|
||||
"timestamp": ts,
|
||||
"id": tvg_id or "Live.Event.us",
|
||||
"link": link,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
## Base Log @ 2025-12-14 20:40 UTC
|
||||
## Base Log @ 2025-12-15 20:44 UTC
|
||||
|
||||
### ✅ Working Streams: 143<br>❌ Dead Streams: 3
|
||||
### ✅ Working Streams: 145<br>❌ Dead Streams: 1
|
||||
|
||||
| Channel | Error (Code) | Link |
|
||||
| ------- | ------------ | ---- |
|
||||
| FDSN Florida | HTTP Error (403) | `http://cord-cutter.net:8080/k4Svp2/645504/46794` |
|
||||
| Spectrum SportsNet LA Dodgers | HTTP Error (502) | `http://cord-cutter.net:8080/k4Svp2/645504/31636` |
|
||||
| getTV | HTTP Error (403) | `http://cord-cutter.net:8080/k4Svp2/645504/18366` |
|
||||
---
|
||||
#### Base Channels URL
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue