2025-08-17 10:05:09 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import json
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
import httpx
|
|
|
|
|
from scrape import fstv, tvpass
|
|
|
|
|
|
|
|
|
|
m3u8_file = Path(__file__).parent / "TV.m3u8"
|
|
|
|
|
|
2025-08-19 10:54:50 -04:00
|
|
|
base_url = "https://spoo.me/yBR2jV"
|
2025-08-17 10:05:09 -04:00
|
|
|
|
2025-08-17 17:01:52 -04:00
|
|
|
client = httpx.Client(
|
|
|
|
|
timeout=5,
|
|
|
|
|
follow_redirects=True,
|
|
|
|
|
headers={
|
|
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0"
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-17 10:05:09 -04:00
|
|
|
|
|
|
|
|
def vanilla_fetch() -> tuple[list[str], int]:
|
|
|
|
|
print("Fetching base M3U8")
|
|
|
|
|
|
|
|
|
|
try:
|
2025-08-19 10:54:50 -04:00
|
|
|
r = client.get(base_url)
|
2025-08-17 10:05:09 -04:00
|
|
|
r.raise_for_status()
|
|
|
|
|
except Exception as e:
|
2025-08-19 10:54:50 -04:00
|
|
|
raise SystemExit(f'Failed to fetch "{base_url}"\n{e}') from e
|
2025-08-17 10:05:09 -04:00
|
|
|
|
|
|
|
|
d = r.text.splitlines()
|
|
|
|
|
|
|
|
|
|
d.pop(0)
|
|
|
|
|
|
|
|
|
|
last_chnl_number = int(r.text.split("tvg-chno=")[-1].split('"')[1])
|
|
|
|
|
|
|
|
|
|
return d, last_chnl_number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2025-08-19 10:54:50 -04:00
|
|
|
tvpass.main(client)
|
2025-08-17 10:05:09 -04:00
|
|
|
|
2025-08-17 17:01:52 -04:00
|
|
|
fstv.main(client)
|
2025-08-17 10:05:09 -04:00
|
|
|
|
|
|
|
|
base_m3u8, chnl_number = vanilla_fetch()
|
|
|
|
|
|
2025-08-17 17:01:52 -04:00
|
|
|
additions = {**tvpass.urls, **fstv.urls}
|
|
|
|
|
|
|
|
|
|
lines = []
|
|
|
|
|
|
|
|
|
|
for event, url in additions.items():
|
|
|
|
|
chnl_number += 1
|
|
|
|
|
lines.append(
|
|
|
|
|
f'#EXTINF:-1 tvg-chno="{chnl_number}"'
|
|
|
|
|
f' tvg-id="(N/A)" tvg-name="{event}"'
|
|
|
|
|
' tvg-logo="https://i.gyazo.com/ec27417a9644ae517196494afa72d2b9.png"'
|
|
|
|
|
f' group-title="Live Events",{event}\n{url}\n'
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-17 10:05:09 -04:00
|
|
|
m3u8_file.write_text(
|
|
|
|
|
'#EXTM3U url-tvg="https://raw.githubusercontent.com/doms9/iptv/refs/heads/default/EPG/TV.xml"\n'
|
|
|
|
|
+ "\n".join(base_m3u8)
|
2025-08-17 17:28:06 -04:00
|
|
|
+ "\n"
|
|
|
|
|
+ "".join(lines)
|
2025-08-17 10:05:09 -04:00
|
|
|
+ "\n",
|
|
|
|
|
encoding="utf-8",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
print(f"M3U8 saved to {m3u8_file.name}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|