From 1ea57865adfa04aad01a86888024f6a5b4579be7 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Thu, 4 Aug 2022 09:46:30 +0100 Subject: [PATCH] PSSH: Fix usage of WidevinePsshData's key_ids field --- pywidevine/pssh.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pywidevine/pssh.py b/pywidevine/pssh.py index c36b47f..5dc9a08 100644 --- a/pywidevine/pssh.py +++ b/pywidevine/pssh.py @@ -47,7 +47,7 @@ class PSSH: cenc_header.algorithm = 1 # 0=Clear, 1=AES-CTR for key_id in key_ids: - cenc_header.key_id.append(key_id.bytes) + cenc_header.key_ids.append(key_id.bytes) if box.version == 1: # ensure both cenc header and box has same Key IDs # v1 uses both this and within init data for basically no reason @@ -66,7 +66,7 @@ class PSSH: """ cenc_header = WidevinePsshData() for key_id in key_ids: - cenc_header.key_id.append(key_id.bytes) + cenc_header.key_ids.append(key_id.bytes) cenc_header.algorithm = 1 # 0=Clear, 1=AES-CTR box = Box.parse(Box.build(dict( @@ -153,7 +153,7 @@ class PSSH: 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()) - for key_id in init.key_id + for key_id in init.key_ids ] if box.system_ID == PSSH.SystemId.PlayReady: @@ -192,12 +192,12 @@ class PSSH: init.ParseFromString(box.init_data) # TODO: Is there a better way to clear the Key IDs? - for _ in range(len(init.key_id or [])): - init.key_id.pop(0) + for _ in range(len(init.key_ids or [])): + init.key_ids.pop(0) # TODO: Is there a .extend or a way to add all without a loop? for key_id in key_ids: - init.key_id.append(key_id.bytes) + init.key_ids.append(key_id.bytes) box.init_data = init.SerializeToString()