From e90371922c33ee414d3df57ddca6cfb99a7aebe7 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Wed, 28 Sep 2022 06:21:28 +0100 Subject: [PATCH] PSSH: Add support for Key IDs of lengths other than 16 bytes This is required for cases like Google's testing DASH manifests, e.g., 'tears' MPD. It assumes the Key ID as a number, which can support up to 16 bytes in this fashion (therefore technically 15 in our scenario as 16 byte Key_IDs can load normally). Fixes #13 --- pywidevine/pssh.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pywidevine/pssh.py b/pywidevine/pssh.py index b6ec5dc..6f275fd 100644 --- a/pywidevine/pssh.py +++ b/pywidevine/pssh.py @@ -199,7 +199,11 @@ class PSSH: cenc_header.ParseFromString(self.init_data) return [ # the key_ids value may or may not be hex underlying - UUID(bytes=key_id) if len(key_id) == 16 else UUID(hex=key_id.decode()) + ( + UUID(bytes=key_id) if len(key_id) == 16 else # normal + UUID(hex=key_id.decode()) if len(key_id) == 32 else # stored as hex + UUID(int=int.from_bytes(key_id, "big")) # assuming as number + ) for key_id in cenc_header.key_ids ]