This commit is contained in:
doms9 2025-10-13 14:17:56 -04:00
parent e49b2217c0
commit 00000d914b
2 changed files with 384 additions and 369 deletions

View file

@ -2,23 +2,16 @@
import asyncio import asyncio
from pathlib import Path from pathlib import Path
from scrapers import ( from scrapers import fstv, streambtw, streameast, streamed, strmd, tvpass, watchfooty
fstv,
livetvsx,
streambtw,
streameast,
streamed,
strmd,
tvpass,
watchfooty,
)
from scrapers.utils import get_logger, network from scrapers.utils import get_logger, network
log = get_logger(__name__) log = get_logger(__name__)
BASE_FILE = Path(__file__).parent / "base.m3u8" BASE_FILE = Path(__file__).parent / "base.m3u8"
M3U8_FILE = Path(__file__).parent / "TV.m3u8" EVENTS_FILE = Path(__file__).parent / "events.m3u8"
COMBINED_FILE = Path(__file__).parent / "TV.m3u8"
def load_base() -> tuple[list[str], int]: def load_base() -> tuple[list[str], int]:
@ -36,7 +29,6 @@ async def main() -> None:
tasks = [ tasks = [
asyncio.create_task(fstv.scrape(network.client)), asyncio.create_task(fstv.scrape(network.client)),
# asyncio.create_task(livetvsx.scrape(network.client)),
asyncio.create_task(streambtw.scrape(network.client)), asyncio.create_task(streambtw.scrape(network.client)),
asyncio.create_task(streameast.scrape(network.client)), asyncio.create_task(streameast.scrape(network.client)),
asyncio.create_task(streamed.scrape(network.client)), asyncio.create_task(streamed.scrape(network.client)),
@ -49,7 +41,6 @@ async def main() -> None:
additions = ( additions = (
fstv.urls fstv.urls
| livetvsx.urls
| streambtw.urls | streambtw.urls
| streameast.urls | streameast.urls
| streamed.urls | streamed.urls
@ -58,25 +49,49 @@ async def main() -> None:
| watchfooty.urls | watchfooty.urls
) )
live_events = [] live_events: list[str] = []
for chnl_num, (event, info) in enumerate( combined_channels: list[str] = []
for i, (event, info) in enumerate(
sorted(additions.items()), sorted(additions.items()),
start=tvg_chno + 1, start=1,
): ):
live_events.extend( extinf_all = (
( f'#EXTINF:-1 tvg-chno="{tvg_chno + i}" tvg-id="{info["id"]}" '
f'\n#EXTINF:-1 tvg-chno="{chnl_num}" tvg-id="{info["id"]}" tvg-name="{event}" tvg-logo="{info["logo"]}" group-title="Live Events",{event}', f'tvg-name="{event}" tvg-logo="{info["logo"]}" group-title="Live Events",{event}'
f'#EXTVLCOPT:http-referrer={info["base"]}',
f'#EXTVLCOPT:http-origin={info["base"]}',
f"#EXTVLCOPT:http-user-agent={network.UA}",
info["url"],
)
) )
M3U8_FILE.write_text("\n".join(base_m3u8 + live_events), encoding="utf-8") extinf_live = (
f'#EXTINF:-1 tvg-chno="{i}" tvg-id="{info["id"]}" '
f'tvg-name="{event}" tvg-logo="{info["logo"]}" group-title="Live Events",{event}'
)
log.info(f"M3U8 saved to {M3U8_FILE.name}") vlc_block = [
f'#EXTVLCOPT:http-referrer={info["base"]}',
f'#EXTVLCOPT:http-origin={info["base"]}',
f"#EXTVLCOPT:http-user-agent={network.UA}",
info["url"],
]
combined_channels.extend(["\n" + extinf_all, *vlc_block])
live_events.extend(["\n" + extinf_live, *vlc_block])
COMBINED_FILE.write_text(
"\n".join(base_m3u8 + combined_channels),
encoding="utf-8",
)
log.info(f"Base + Events saved to {COMBINED_FILE.name}")
EVENTS_FILE.write_text(
'#EXTM3U url-tvg="https://raw.githubusercontent.com/doms9/iptv/refs/heads/default/EPG/TV.xml"\n'
+ "\n".join(live_events),
encoding="utf-8",
)
log.info(f"Events saved to {EVENTS_FILE.name}")
if __name__ == "__main__": if __name__ == "__main__":