From b5e1c3e6a7db05ff9afec14240f4d73996f28a20 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Tue, 11 Aug 2026 21:24:05 -0600 Subject: [PATCH] fix(hls): take the key id from EXT-X-KEY when the PSSH carries none --- unshackle/core/manifests/hls.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/unshackle/core/manifests/hls.py b/unshackle/core/manifests/hls.py index a84d697c..c857707d 100644 --- a/unshackle/core/manifests/hls.py +++ b/unshackle/core/manifests/hls.py @@ -1288,9 +1288,15 @@ class HLS: elif key.method == "ISO-23001-7": drm = Widevine(pssh=WV_PSSH.new(key_ids=[key.uri.split(",")[-1]], system_id=WV_PSSH.SystemId.Widevine)) elif key.keyformat and key.keyformat.lower() == WidevineCdm.urn: + extra_params = dict(key._extra_params) # noqa + # a v0 PSSH carries no KID, leaving the tag's own KEYID as the only source + kid = extra_params.pop("keyid", None) or extra_params.pop("kid", None) + if isinstance(kid, str): + kid = kid.removeprefix("0x").removeprefix("0X") drm = Widevine( pssh=WV_PSSH(key.uri.split(",")[-1]), - **key._extra_params, # noqa + kid=kid, + **extra_params, ) elif key.keyformat and key.keyformat.lower() in {f"urn:uuid:{PR_PSSH.SYSTEM_ID}", "com.microsoft.playready"}: drm = PlayReady(