e
This commit is contained in:
parent
1d464fd2ae
commit
00000d9d40
3 changed files with 24 additions and 149 deletions
27
EPG/fetch.py
27
EPG/fetch.py
|
|
@ -1,16 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import gzip
|
||||
import json
|
||||
import re
|
||||
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_CA2.xml.gz",
|
||||
"https://epgshare01.online/epgshare01/epg_ripper_DUMMY_CHANNELS.xml.gz",
|
||||
"https://epgshare01.online/epgshare01/epg_ripper_ES1.xml.gz",
|
||||
|
|
@ -19,10 +17,8 @@ epg_urls = [
|
|||
"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_LOCALS2.xml.gz",
|
||||
# "https://epgshare01.online/epgshare01/epg_ripper_US_SPORTS1.xml.gz",
|
||||
]
|
||||
|
||||
client = httpx.AsyncClient(
|
||||
|
|
@ -56,6 +52,25 @@ replace_ids = {
|
|||
}
|
||||
|
||||
|
||||
def get_tvg_ids() -> dict[str, str]:
|
||||
base_m3u8 = (
|
||||
(Path(__file__).parent.parent / "M3U8" / "base.m3u8")
|
||||
.read_text(encoding="utf-8")
|
||||
.splitlines()
|
||||
)
|
||||
|
||||
tvg = {}
|
||||
|
||||
for line in base_m3u8:
|
||||
if line.startswith("#EXTINF"):
|
||||
tvg_id = re.search(r'tvg-id="([^"]*)"', line)[1]
|
||||
tvg_logo = re.search(r'tvg-logo="([^"]*)"', line)[1]
|
||||
|
||||
tvg[tvg_id] = tvg_logo
|
||||
|
||||
return tvg
|
||||
|
||||
|
||||
async def fetch_xml(url: str) -> ET.Element | None:
|
||||
try:
|
||||
r = await client.get(url)
|
||||
|
|
@ -122,7 +137,7 @@ def hijack_id(
|
|||
|
||||
|
||||
async def main() -> None:
|
||||
tvg_ids: dict[str, str] = json.loads(tvg_ids_file.read_text(encoding="utf-8"))
|
||||
tvg_ids = get_tvg_ids()
|
||||
|
||||
tvg_ids |= dummies | {v["old"]: live_img for v in replace_ids.values()}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue