VideoHelp Forum




+ Reply to Thread
Results 1 to 9 of 9
  1. psaframe
    Join Date
    Mar 2021
    Location
    Algeria
    Search PM
    script to get mpd link from live channels

    Code:
    import requests
    import json
    from urllib3.exceptions import InsecureRequestWarning
     
    headers = {
        'Host': 'entitlement.tod.tv',
        'Sec-Ch-Ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/json',
        'Sec-Ch-Ua-Mobile': '?0',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
        'Sec-Ch-Ua-Platform': '"Linux"',
        'Origin': 'https://www.tod.tv',
        'Referer': 'https://www.tod.tv/',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'en-US,en;q=0.9,ar;q=0.8',
    }
     
    json_data = {
        'Type': 1,
        'User': 'YOUR_TOKEN_HERE',
        'VideoId': '0522e9b1-66ad-4e7d-b2b3-779ba106809a',
        'VideoSource': 'https://live-d-main-beinmena.beincdn.com/ch10/59f4d245-04d1-460e-92e7-07714ddc7c3f/59f4d245-04d1-460e-92e7-07714ddc7c3f.ism/manifest(format=mpd-time-csf,filter=desktop-fullres,encryption=cenc)',
        'VideoKind': '',
        'AssetState': '2',
        'PlayerType': 'HTML5',
        'VideoSourceFormat': 'DASH',
        'VideoSourceName': 'Desktop-DASH',
        'DRMType': 'widevine',
        'AuthType': 'Token',
        'ContentKeyData': 'd3336025-54a5-44fe-93be-3a68991f4f0d',
        'Other': '52346197-E22B-1470-C8E8-38F76BBC4AAD|HTML5|HTML5_Web|%2Fwatch%2Fsoccer-premier-league-newcastle-united-vs-tottenham-hotspur-199386|54d1b6e1-dbb4-4a5c-962f-b78d759a0333',
    }
     
    requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
     
    response1 = requests.post(
        'https://entitlement.tod.tv/entitlement/api/video/azure/diva/open',
        headers=headers,
        json=json_data,
        verify=False,
    )
     
    body = json.loads(response1.text)
     
    headers2 = {
        'Host': 'live-d-main-beinmena.beincdn.com',
        # 'Content-Length': '1534',
        'Sec-Ch-Ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"',
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/json',
        'Sec-Ch-Ua-Mobile': '?0',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
        'Sec-Ch-Ua-Platform': '"Linux"',
        'Origin': 'https://www.tod.tv',
        'Sec-Fetch-Site': 'same-site',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Dest': 'empty',
        'Referer': 'https://www.tod.tv/',
        # 'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'en-US,en;q=0.9,ar;q=0.8',
    }
     
    requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
     
    response2 = requests.get(
        body["ContentUrl"],
        allow_redirects=False,
        headers=headers2,
        verify=False,
    )
    print("TOD URL ## -->:")
    print(response2.headers["Location"])
    exit()
    Quote Quote  
  2. Member
    Join Date
    Jun 2022
    Location
    PARIS
    Search PM
    if possible add request dynamic 'token' 'ContentKeyData' 'Other'
    Last edited by ORSA; 29th Dec 2023 at 11:50.
    Quote Quote  
  3. Member
    Join Date
    Feb 2024
    Location
    earth
    Search PM
    @naim2007
    they has been updated their site, and urls changed, could you make another one to get mpd link?
    Quote Quote  
  4. Originally Posted by ginoza View Post
    @naim2007
    they has been updated their site, and urls changed, could you make another one to get mpd link?
    Code:
    import requests
    import json
    from http.cookiejar import MozillaCookieJar
    
    def get_cookies(cookiefile):
        cj = MozillaCookieJar(cookiefile, policy=False)
        cj.load(ignore_discard=True, ignore_expires=True)
    return {cookie.name: cookie.value for cookie in cj}
    
    
    req = requests.Session()
    req.cookies.update(get_cookies()) # update your cookies 
    id = ''# channel id e.g. 5003195
    
    url = "https://www.tod.tv/api/service"
    headers = { 
    "Content-Type": "application/json"
    }
    
    
    payload = {
    "requestInit": {
    "method": "POST",
    "body": json.dumps({
    "contentId":id,
    "playRequestType": "CHANNEL",
    "internetConnectionType": "WIFI",
    "streamFormatType": "DASH",
    "alternativeStreamFormat": "HLS",
    "contentType": "CHANNEL"
                    }),
        },
    "skipAPIKeyControl": False,
    "url": "http://tod2-mw-play-prod.mw-play.svc.cluster.local/api/v1/play/cdn"
    }
    
    response = req.post( url, json=payload, headers=headers)
    
    cdnUri = response.json()['data']['cdnInfos'][0]['cdnUri']
    hashValue = response.json()['data']['hashValue']
    
    licenseStartDate =response.json()['data']['licenseStartDate']
    mediaId = response.json()['data']['cdnInfos'][0]['mediaId']
    
    payload = {
    "requestInit": {
    "method": "POST",
    "body": json.dumps({
    "contentId": id,
    "assetId": id,
    "cdnProvider": "Akamai",
    "cdnUri": cdnUri,
    "hashValue": hashValue,
    "playRequestType": "CHANNEL",
    "streamFormatType": "DASH",
    "alternativeStreamFormat": "HLS",
    "licenseStartDate":licenseStartDate ,
    "rulesetModel": [
                    {"key": "downloadedDevices"    , "value": "5"       },
                    {"key": "maxactivestreams"     , "value": "2"       },
                    {"key": "maxvodstreams"        , "value": "2"       },
                    {"key": "maxliveandvodsports"  , "value": "2"       },
                    {"key": "defaultResolution"    , "value": "1080"    },
                    {"key": "audioQuality"         , "value": "Standard"},
                    {"key": "videoQuality"         , "value": "Better"  },
                    {"key": "allowCasting"         , "value": "True"    },
                    {"key": "allowOfflineDownload" , "value": "True"    },
                    {"key": "registeredDeviceLimit", "value": "5"       }
                ],
    "packageTags": ["u-false", "e-false"],
    "cardType": "Total"
                })
    
        },
    "skipAPIKeyControl": False,
    "url": "http://tod2-mw-play-prod.mw-play.svc.cluster.local/api/v1/play/ticket"
    }
    
    response = req.post( url, json=payload, headers=headers)
    for tickets in response.json()['data']['tickets']:
        if tickets['ticketType'] == "CDN":
            ticket = tickets['ticket']
            mpd = cdnUri+ f"?{ticket}"
            print(mpd)
    
    Last edited by notaghost; 22nd Mar 2025 at 16:57.
    discord=notaghost9997
    Quote Quote  
  5. Member
    Join Date
    Feb 2024
    Location
    earth
    Search PM
    Originally Posted by notaghost View Post
    Originally Posted by ginoza View Post
    @naim2007
    they has been updated their site, and urls changed, could you make another one to get mpd link?
    Code:
    import requests
    import json
    from http.cookiejar import MozillaCookieJar
    
    def get_cookies(cookiefile):
        cj = MozillaCookieJar(cookiefile, policy=False)
        cj.load(ignore_discard=True, ignore_expires=True)
    return {cookie.name: cookie.value for cookie in cj}
    
    
    req = requests.Session()
    req.cookies.update(get_cookies()) # update your cookies 
    id = ''# channel id e.g. 5003195
    
    url = "https://www.tod.tv/api/service"
    headers = { 
    "Content-Type": "application/json"
    }
    
    
    payload = {
    "requestInit": {
    "method": "POST",
    "body": json.dumps({
    "contentId":id,
    "playRequestType": "CHANNEL",
    "internetConnectionType": "WIFI",
    "streamFormatType": "DASH",
    "alternativeStreamFormat": "HLS",
    "contentType": "CHANNEL"
                    }),
        },
    "skipAPIKeyControl": False,
    "url": "http://tod2-mw-play-prod.mw-play.svc.cluster.local/api/v1/play/cdn"
    }
    
    response = req.post( url, json=payload, headers=headers)
    
    cdnUri = response.json()['data']['cdnInfos'][0]['cdnUri']
    hashValue = response.json()['data']['hashValue']
    
    licenseStartDate =response.json()['data']['licenseStartDate']
    mediaId = response.json()['data']['cdnInfos'][0]['mediaId']
    
    payload = {
    "requestInit": {
    "method": "POST",
    "body": json.dumps({
    "contentId": id,
    "assetId": id,
    "cdnProvider": "Akamai",
    "cdnUri": cdnUri,
    "hashValue": hashValue,
    "playRequestType": "CHANNEL",
    "streamFormatType": "DASH",
    "alternativeStreamFormat": "HLS",
    "licenseStartDate":licenseStartDate ,
    "rulesetModel": [
                    {"key": "downloadedDevices"    , "value": "5"       },
                    {"key": "maxactivestreams"     , "value": "2"       },
                    {"key": "maxvodstreams"        , "value": "2"       },
                    {"key": "maxliveandvodsports"  , "value": "2"       },
                    {"key": "defaultResolution"    , "value": "1080"    },
                    {"key": "audioQuality"         , "value": "Standard"},
                    {"key": "videoQuality"         , "value": "Better"  },
                    {"key": "allowCasting"         , "value": "True"    },
                    {"key": "allowOfflineDownload" , "value": "True"    },
                    {"key": "registeredDeviceLimit", "value": "5"       }
                ],
    "packageTags": ["u-false", "e-false"],
    "cardType": "Total"
                })
    
        },
    "skipAPIKeyControl": False,
    "url": "http://tod2-mw-play-prod.mw-play.svc.cluster.local/api/v1/play/ticket"
    }
    
    response = req.post( url, json=payload, headers=headers)
    for tickets in response.json()['data']['tickets']:
        if tickets['ticketType'] == "CDN":
            ticket = tickets['ticket']
            mpd = cdnUri+ f"?{ticket}"
            print(mpd)
    
    awesome thanks bro

    can you please explain how to use it with cookies and what is requirement to get it work,
    another question can you make this script get cookies auto to get mpd link
    i can give you my account if needed.

    thanks again.
    Quote Quote  
  6. Member
    Join Date
    Feb 2024
    Location
    earth
    Search PM
    @notaghost
    i have sent pm to you
    Quote Quote  
  7. Originally Posted by ginoza View Post
    Originally Posted by notaghost View Post
    Originally Posted by ginoza View Post
    @naim2007
    they has been updated their site, and urls changed, could you make another one to get mpd link?
    Code:
    import requests
    import json
    from http.cookiejar import MozillaCookieJar
    
    def get_cookies(cookiefile):
        cj = MozillaCookieJar(cookiefile, policy=False)
        cj.load(ignore_discard=True, ignore_expires=True)
    return {cookie.name: cookie.value for cookie in cj}
    
    
    req = requests.Session()
    req.cookies.update(get_cookies()) # update your cookies 
    id = ''# channel id e.g. 5003195
    
    url = "https://www.tod.tv/api/service"
    headers = { 
    "Content-Type": "application/json"
    }
    
    
    payload = {
    "requestInit": {
    "method": "POST",
    "body": json.dumps({
    "contentId":id,
    "playRequestType": "CHANNEL",
    "internetConnectionType": "WIFI",
    "streamFormatType": "DASH",
    "alternativeStreamFormat": "HLS",
    "contentType": "CHANNEL"
                    }),
        },
    "skipAPIKeyControl": False,
    "url": "http://tod2-mw-play-prod.mw-play.svc.cluster.local/api/v1/play/cdn"
    }
    
    response = req.post( url, json=payload, headers=headers)
    
    cdnUri = response.json()['data']['cdnInfos'][0]['cdnUri']
    hashValue = response.json()['data']['hashValue']
    
    licenseStartDate =response.json()['data']['licenseStartDate']
    mediaId = response.json()['data']['cdnInfos'][0]['mediaId']
    
    payload = {
    "requestInit": {
    "method": "POST",
    "body": json.dumps({
    "contentId": id,
    "assetId": id,
    "cdnProvider": "Akamai",
    "cdnUri": cdnUri,
    "hashValue": hashValue,
    "playRequestType": "CHANNEL",
    "streamFormatType": "DASH",
    "alternativeStreamFormat": "HLS",
    "licenseStartDate":licenseStartDate ,
    "rulesetModel": [
                    {"key": "downloadedDevices"    , "value": "5"       },
                    {"key": "maxactivestreams"     , "value": "2"       },
                    {"key": "maxvodstreams"        , "value": "2"       },
                    {"key": "maxliveandvodsports"  , "value": "2"       },
                    {"key": "defaultResolution"    , "value": "1080"    },
                    {"key": "audioQuality"         , "value": "Standard"},
                    {"key": "videoQuality"         , "value": "Better"  },
                    {"key": "allowCasting"         , "value": "True"    },
                    {"key": "allowOfflineDownload" , "value": "True"    },
                    {"key": "registeredDeviceLimit", "value": "5"       }
                ],
    "packageTags": ["u-false", "e-false"],
    "cardType": "Total"
                })
    
        },
    "skipAPIKeyControl": False,
    "url": "http://tod2-mw-play-prod.mw-play.svc.cluster.local/api/v1/play/ticket"
    }
    
    response = req.post( url, json=payload, headers=headers)
    for tickets in response.json()['data']['tickets']:
        if tickets['ticketType'] == "CDN":
            ticket = tickets['ticket']
            mpd = cdnUri+ f"?{ticket}"
            print(mpd)
    
    awesome thanks bro

    can you please explain how to use it with cookies and what is requirement to get it work,
    another question can you make this script get cookies auto to get mpd link
    i can give you my account if needed.

    thanks again.
    any iptv panel to add it in
    Quote Quote  
  8. After extensive reverse engineering, I’ve successfully developed a Bash script that communicates with the TOD streaming backend to simulate a full channel play request flow.

    ✅ What the script already achieves:
    • Sends a fully authenticated request using a valid Bearer token and proper headers.
    • Extracts key response data including:
    • cdnUri
    • cdnProvider
    • hashValue
    • rulesetModel
    • licenseStartDate
    • packageTags
    • Modifies the rulesetModel to increase stream and device limits.
    • Constructs and sends the second structured payload to request playback.
    • Validates all JSON responses and ensures no missing critical data.
    • Prepares all the necessary values that are used in FairPlay DRM sessions.

    🔐 What’s missing:
    To complete the streaming process, I still need to:
    • Correctly initiate and handle FairPlay DRM playback.
    • Pass the extracted ckc, sks, and DRM values to a working AVPlayer or compatible player.
    • Emulate or handle the AVContentKeySession lifecycle, including fetching and decrypting the CKC (Content Key Context).

    🧠 If you have expertise in FairPlay integration or know how to securely inject DRM parameters into iOS/macOS,,, whatever ! players, I’d appreciate any insight or collaboration.Image
    [Attachment 86877 - Click to enlarge]
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!