fix(hls): bridge a stitched one-key FairPlay playlist with an all-zero tenc KID

This commit is contained in:
imSp4rky
2026-12-01 17:03:56 -07:00
parent 90ab0ca4cb
commit f680df7eff
4 changed files with 267 additions and 22 deletions
+7 -1
View File
@@ -20,7 +20,7 @@ from unshackle.core.config import config
from unshackle.core.constants import AnyTrack
from unshackle.core.drm import key_args as drm_key_args
from unshackle.core.drm.decrypters import decrypt_cenc, mp4decrypt, shaka_decrypt
from unshackle.core.drm.verify import PIFF_TENC
from unshackle.core.drm.verify import PIFF_TENC, TENC, has_encrypted_entry, walk
from unshackle.core.session import AnySession, utf8_text
from unshackle.core.utilities import get_boxes
from unshackle.core.utils import run_proxy
@@ -121,6 +121,12 @@ def init_pssh_kid(init_data: bytes) -> UUID | None:
return kids.pop() if len(kids) == 1 else None
def is_clear_init(init_data: bytes) -> bool:
"""True when a complete init segment names no encrypted sample entry and no tenc."""
complete = any(kind == b"stsd" for kind, _, _ in walk(init_data))
return complete and not has_encrypted_entry(init_data) and not any(tenc in init_data for tenc in TENC)
def hls_key_drm(key: Any, kid: UUID | None = None) -> Widevine | PlayReady | None:
"""The Widevine or PlayReady DRM of an EXT-X-KEY, or None for another KEYFORMAT.