400 error bad request
Closed this issue · 1 comments
from pywidevine.cdm import Cdm
from pywidevine.device import Device
from pywidevine.pssh import PSSH
from base64 import b64encode
import base64
import requests
import json
url = "https://cox-mds.az.cox.comcast.net/license"
#requestc = b64encode(challenge)
#response = requests.request("POST", url, headers=headers, data=payload)
prepare pssh
pssh = PSSH("AAAAW3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADsSJDk5NjllYWJjLWE3ZmUtMDk2Yi1jZjQzLWZmNzYwNGUwZjljNSITODI5MTA3NDQwMzczMDYyNDE2Mw==")
load device
device = Device.load("device.wvd")
load cdm
cdm = Cdm.from_device(device)
open cdm session
session_id = cdm.open()
get license challenge
challenge = cdm.get_license_challenge(session_id, pssh)
print(b64encode(challenge))
payload = {"keySystem":"widevine",
"licenseRequest": b64encode(challenge),
"contentMetadata":"","mediaUsage":"stream","accessToken":""}
headers = {
"Accept": "application/vnd.xcal.mds.licenseResponse+json; version=1",
"Accept-Language": "en-US,en;q=0.9",
"Connection": "keep-alive",
"Content-Type": "application/vnd.xcal.mds.licenseRequest+json; version=1",
"Origin": "https://watchtv.cox.com",
"Referer": "https://watchtv.cox.com/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36",
"X-MoneyTrace": ""
}
send license challenge (assuming a generic license server SDK with no API front)
licence = requests.post(url, headers=headers, data=payload)
#print(license.text)
licence.raise_for_status()
l = response.json()['license']
print(l)
parse license challenge
cdm.parse_license(session_id, l)
print keys
for key in cdm.get_keys(session_id):
print(f"[{key.type}] {key.kid.hex}:{key.key.hex()}")
close session, disposes of session data
cdm.close(session_id)
this code is giving 400 error if you can correct it
I do not provide support for API fronts on License Acquisition Servers. This is likely some kind of authorization or mistake with the API calls. I will not provide support for this.