This commit is contained in:
doms9 2025-09-18 17:31:45 -04:00
parent 839b38612b
commit 00000d99bf
6 changed files with 536 additions and 216 deletions

View file

@ -1,20 +1,26 @@
#!/usr/bin/env python3
import asyncio
import gzip
import json
from pathlib import Path
from xml.etree import ElementTree as ET
import httpx
tvg_ids_file = Path(__file__).parent / "TVG-IDs.json"
epg_file = Path(__file__).parent / "TV.xml"
epg_urls = [
"https://epgshare01.online/epgshare01/epg_ripper_CA1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_ES1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_FANDUEL1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_MY1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_PLEX1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_PT1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_UK1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_US1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_US2.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_US_SPORTS1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_US_LOCALS2.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_FANDUEL1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_CA1.xml.gz",
"https://epgshare01.online/epgshare01/epg_ripper_US_SPORTS1.xml.gz",
]
client = httpx.AsyncClient(
@ -26,16 +32,6 @@ client = httpx.AsyncClient(
)
async def fetch_tvg_ids() -> dict[str, str]:
try:
r = await client.get("https://s.id/4dqiO")
r.raise_for_status()
except Exception as e:
raise SystemExit(f"Failed to fetch TVG IDs\n{e}") from e
return r.json()
async def fetch_xml(url: str) -> ET.Element:
try:
r = await client.get(url)
@ -53,7 +49,9 @@ async def fetch_xml(url: str) -> ET.Element:
async def main() -> None:
tvg_ids = await fetch_tvg_ids()
data = json.loads(tvg_ids_file.read_text(encoding="utf-8"))
tvg_ids = {v["tvg-id"]: v["logo"] for v in data.values()}
root = ET.Element("tv")