Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WASU IPTV box to m3u8 file

Fetch channels from WASU IPTV box web API and generate m3u8 from return data.

#!/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