import requests from urllib.parse import quote from urllib.request import Request, urlopen print(f"[*] DSTV MPD Generator") auth_token = "" # Your ID Token profile_id = "" # Your Profile ID channel_id = "MZE" # Channel ID smil_url = "https://r-live-cache.akamaized.net/USL04/MZE/MZE.isml/.mpd?hdnts={}&ssai=dD1QUjpEc3R2LFBBOkNPTVBBQ1QsU0M6TGluZWFyJmdkcHI9MCZnZHByX2NvbnNlbnQ9MCZnZHByX3BkPTAmcGlkPUY1QUUzWEZMQVROQzNRRTZFV1JHODlXTzAwMUkmZGNpZD1kZXNrdG9wJnBmPWh0bWw1&filter=%28type%3D%3D%22video%22%26%26MaxHeight%3C%3D1080%29%7C%7C%28%28type%3D%3D%22audio%22%26%26systemBitrate%3E50000%29%29" #smil url if auth_token == "" or profile_id == "": print(f"[*] Please fill your ID Token and Profile ID") exit() headers = { "authorization": auth_token, "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36", "Origin": "https://now.dstv.com", "Referer": "https://now.dstv.com/", "x-profile-id": profile_id } print(f"[*] Getting Akamai Token for {channel_id} .....") r = requests.post( f"https://ssl.dstv.com/api/dstv_now/play_stream/access_token?channel_tag={channel_id}", headers=headers) json_resp = r.json() if "access_token" in json_resp: print(f"[*] Finished for getting Akamai Token for {channel_id} .....") akamai_token = quote(json_resp["access_token"]).replace( "%7E", "~").replace("/", "%2F").replace("%2A", "*") headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36", "Origin": "https://now.dstv.com", "Referer": "https://now.dstv.com/", "Accept": "*/*", "Authority": "r-live-cache.akamaized.net", "accept-language": "en-GB,en-US;q=0.9,en;q=0.8" } r = requests.get(smil_url.format(akamai_token), headers=headers, allow_redirects=False) if r.status_code == 301 or r.status_code == 302: mpd_url = r.headers["Location"] print(f"[*] Got Tokenized MPD for {channel_id} : {mpd_url}") r = requests.get(mpd_url, headers=headers, allow_redirects=False) print(f"[*] Got MPD for {channel_id} : {r.text}") else: print(f"[*] Failed to get Akamai Token for {channel_id} .....") print(f"[*] Response : {json_resp}") print("[*] Finished")