forked from kenzuya/unshackle
refactor(drm): build PlayReady from base64 with PlayReady.from_pssh_b64 in server keys and the wire rebuild
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import logging
|
||||
import uuid
|
||||
from collections.abc import Callable, Iterable, Sequence
|
||||
@@ -322,11 +321,9 @@ def client_track_kid(kid_hex: Any, track: Any) -> uuid.UUID | None:
|
||||
def pssh_kids(pssh_b64: str, drm_type: str) -> set:
|
||||
"""The KIDs a base64 PSSH names, for either DRM system."""
|
||||
if drm_type == "playready":
|
||||
from pyplayready.system.pssh import PSSH as PlayReadyPSSH
|
||||
|
||||
from unshackle.core.drm import PlayReady
|
||||
|
||||
return set(PlayReady(pssh=PlayReadyPSSH(base64.b64decode(pssh_b64)), pssh_b64=pssh_b64).kids)
|
||||
return set(PlayReady.from_pssh_b64(pssh_b64).kids)
|
||||
from pywidevine.pssh import PSSH as WvPSSH
|
||||
|
||||
from unshackle.core.drm import Widevine
|
||||
@@ -403,14 +400,11 @@ def handle_single_server_cdm(
|
||||
raise refusal or APIError(APIErrorCode.NO_CONTENT, "The server vault holds no content key for this track")
|
||||
|
||||
if drm_type == "playready":
|
||||
from pyplayready.system.pssh import PSSH as PlayReadyPSSH
|
||||
|
||||
from unshackle.core.drm import PlayReady
|
||||
|
||||
pr_pssh = PlayReadyPSSH(base64.b64decode(pssh_b64))
|
||||
siblings = [d for d in (getattr(track, "drm", None) or []) if isinstance(d, PlayReady)]
|
||||
manifest_kid = next((getattr(d, "kid", None) for d in siblings if getattr(d, "kid", None)), None)
|
||||
pr_drm = PlayReady(pssh=pr_pssh, pssh_b64=pssh_b64, kid=manifest_kid)
|
||||
pr_drm = PlayReady.from_pssh_b64(pssh_b64, kid=manifest_kid)
|
||||
if siblings:
|
||||
pr_drm.absorb(*siblings)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user