Skip to content

Instantly share code, notes, and snippets.

Last active January 30, 2020 13:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ttimasdf/39b0df75b3485e8bc4fe4af755506f2b to your computer and use it in GitHub Desktop.
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"
def main():
if True: # Use remote channel list
resp = requests.get(INPUT_URL, allow_redirects=True)
data = resp.json()
with open(INPUT_FILE) as f:
data = json.load(f)
# print(data)
with open(OUTPUT_FILE, 'w') as f:
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}" ')
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment