diff --git a/pywidevine/remotecdm.py b/pywidevine/remotecdm.py index 37b0cc5..bbe996e 100644 --- a/pywidevine/remotecdm.py +++ b/pywidevine/remotecdm.py @@ -228,7 +228,7 @@ class RemoteCdm(Cdm): ) r = self.__session.post( - url=f"{self.host}/{self.device_name}/parse_license/ALL", + url=f"{self.host}/{self.device_name}/parse_license", json={ "session_id": session_id.hex(), "license_message": base64.b64encode(license_message.SerializeToString()).decode() @@ -236,17 +236,6 @@ class RemoteCdm(Cdm): ) if r.status_code != 200: raise ValueError(f"Cannot parse License, {r.text} [{r.status_code}]") - r = r.json()["data"] - - session.keys = [ - Key( - type_=key["type"], - kid=Key.kid_to_uuid(bytes.fromhex(key["key_id"])), - key=bytes.fromhex(key["key"]), - permissions=key["permissions"] - ) - for key in r["keys"] - ] def get_keys(self, session_id: bytes, type_: Optional[Union[int, str]] = None) -> list[Key]: try: diff --git a/pywidevine/serve.py b/pywidevine/serve.py index d29e388..c70c55c 100644 --- a/pywidevine/serve.py +++ b/pywidevine/serve.py @@ -245,13 +245,10 @@ async def get_license_challenge(request: web.Request) -> web.Response: }, status=200) -@routes.post("/{device}/parse_license/{key_type}") +@routes.post("/{device}/parse_license") async def parse_license(request: web.Request) -> web.Response: secret_key = request.headers["X-Secret-Key"] device_name = request.match_info["device"] - key_type = request.match_info["key_type"] - if key_type == "ALL": - key_type = None body = await request.json() for required_field in ("session_id", "license_message"): @@ -296,37 +293,9 @@ async def parse_license(request: web.Request) -> web.Response: "message": "Signature Validation failed on the License Message, rejecting." }, status=400) - # get keys - try: - keys = cdm.get_keys(session_id, key_type) - except InvalidSession: - return web.json_response({ - "status": 400, - "message": f"Invalid Session ID '{session_id.hex()}', it may have expired." - }, status=400) - except ValueError as e: - return web.json_response({ - "status": 400, - "message": f"The Key Type value '{key_type}' is invalid, {e}" - }, status=400) - - # get the keys in json form - keys_json = [ - { - "key_id": key.kid.hex, - "key": key.key.hex(), - "type": key.type, - "permissions": key.permissions, - } - for key in keys - ] - return web.json_response({ "status": 200, - "message": "Success", - "data": { - "keys": keys_json - } + "message": "Successfully parsed and loaded the Keys from the License message." })