e
This commit is contained in:
parent
73f28024ac
commit
00000d9822
6 changed files with 125 additions and 180 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
|
|
@ -8,7 +9,7 @@ m3u8_file = Path(__file__).parent / "TV.m3u8"
|
|||
|
||||
base_url = "https://s.id/ePwXT"
|
||||
|
||||
client = httpx.Client(
|
||||
client = httpx.AsyncClient(
|
||||
timeout=5,
|
||||
follow_redirects=True,
|
||||
headers={
|
||||
|
|
@ -17,49 +18,44 @@ client = httpx.Client(
|
|||
)
|
||||
|
||||
|
||||
def vanilla_fetch() -> tuple[list[str], int]:
|
||||
async def vanilla_fetch() -> tuple[list[str], int]:
|
||||
print("Fetching base M3U8")
|
||||
|
||||
try:
|
||||
r = client.get(base_url)
|
||||
r = await client.get(base_url)
|
||||
r.raise_for_status()
|
||||
except Exception as e:
|
||||
raise SystemExit(f'Failed to fetch "{base_url}"\n{e}') from e
|
||||
|
||||
d = r.text.splitlines()
|
||||
|
||||
d.pop(0)
|
||||
d = r.text.splitlines()[1:]
|
||||
|
||||
last_chnl_number = int(r.text.split("tvg-chno=")[-1].split('"')[1])
|
||||
|
||||
return d, last_chnl_number
|
||||
|
||||
|
||||
def main() -> None:
|
||||
tvpass.main(client)
|
||||
async def main() -> None:
|
||||
await tvpass.main(client)
|
||||
|
||||
fstv.main(client)
|
||||
await fstv.main(client)
|
||||
|
||||
base_m3u8, chnl_number = vanilla_fetch()
|
||||
base_m3u8, chnl_number = await vanilla_fetch()
|
||||
|
||||
additions = tvpass.urls | fstv.urls
|
||||
|
||||
lines = []
|
||||
|
||||
for event, url in sorted(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'
|
||||
lines = [
|
||||
f'#EXTINF:-1 tvg-chno="{chnl_number}" tvg-id="(N/A)" tvg-name="{event}" tvg-logo="https://i.gyazo.com/ec27417a9644ae517196494afa72d2b9.png" group-title="Live Events",{event}\n{url}'
|
||||
for chnl_number, (event, url) in enumerate(
|
||||
sorted(additions.items()),
|
||||
start=chnl_number + 1,
|
||||
)
|
||||
]
|
||||
|
||||
m3u8_file.write_text(
|
||||
'#EXTM3U url-tvg="https://raw.githubusercontent.com/doms9/iptv/refs/heads/default/EPG/TV.xml"\n'
|
||||
+ "\n".join(base_m3u8)
|
||||
+ "\n"
|
||||
+ "".join(lines)
|
||||
+ "\n".join(lines)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
|
@ -68,4 +64,4 @@ def main() -> None:
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue