Fetch channels from WASU IPTV box web API and generate m3u8 from return data.
Last active
January 30, 2020 13:04
-
-
Save ttimasdf/39b0df75b3485e8bc4fe4af755506f2b to your computer and use it in GitHub Desktop.
WASU IPTV box to m3u8 file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
import json | |
INPUT_URL = "http://REDACTED/live_sxlt_playback_v2.shtml" | |
INPUT_FILE = "channel-list.json" | |
OUTPUT_FILE = "iptv-channels.m3u8" | |
# https://siptv.eu/howto/playlist.html | |
def main(): | |
if True: # Use remote channel list | |
resp = requests.get(INPUT_URL, allow_redirects=True) | |
data = resp.json() | |
else: | |
with open(INPUT_FILE) as f: | |
data = json.load(f) | |
# print(data) | |
# https://siptv.eu/howto/playlist.html | |
with open(OUTPUT_FILE, 'w') as f: | |
f.write('#EXTM3U\n') | |
for chan in data["channels"]: | |
playctx = chan["playUrl"] | |
tvg_id = playctx["channelID"] | |
tvg_name = chan["channelName"] | |
group_title = chan["type"] | |
tvg_logo = chan["picUrl"] | |
url = playctx["httpUrl"] | |
f.write('#EXTINF:-1 aspect-ratio="16:9" ') | |
if tvg_id: | |
f.write(f'tvg-id="{tvg_id}" ') | |
if tvg_name: | |
f.write(f'tvg-name="{tvg_name}" ') | |
if group_title: | |
f.write(f'group-title="{group_title}" ') | |
if tvg_logo: | |
f.write(f'tvg-logo="{tvg_logo}" ') | |
f.write(f',{tvg_name}\n{url}\n') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment