mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-02 05:55:08 +00:00
feat(hls): license a FairPlay-only SAMPLE-AES playlist through a PlayReady or Widevine CDM
This commit is contained in:
@@ -101,6 +101,26 @@ def init_kid(init_data: bytes) -> UUID | None:
|
||||
return None
|
||||
|
||||
|
||||
def init_pssh_kid(init_data: bytes) -> UUID | None:
|
||||
"""The one real KID that every pssh box of an init segment with a tenc names, or None for none or several."""
|
||||
from unshackle.core.drm.playready import PlayReady
|
||||
from unshackle.core.drm.widevine import Widevine
|
||||
|
||||
if not any(get_boxes(init_data, b"tenc")):
|
||||
return None
|
||||
drm_classes: dict[UUID, type[CencDrm]] = {WIDEVINE_ID: Widevine, PLAYREADY_ID: PlayReady}
|
||||
kids: set[UUID] = set()
|
||||
for box in get_boxes(init_data, b"pssh"):
|
||||
kids.update(box.key_IDs or [])
|
||||
if drm_class := drm_classes.get(box.system_ID):
|
||||
try:
|
||||
kids.update(drm_class.from_pssh_box(box, None).kids)
|
||||
except drm_class.Exceptions.KIDNotFound:
|
||||
continue
|
||||
kids -= PLACEHOLDER_KIDS
|
||||
return kids.pop() if len(kids) == 1 else None
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user