refactor(drm): build PlayReady from base64 with PlayReady.from_pssh_b64 in server keys and the wire rebuild

This commit is contained in:
imSp4rky
2026-11-29 11:35:37 -07:00
parent 1cbaa2d307
commit 0ba9e6dfed
12 changed files with 182 additions and 55 deletions
@@ -11,7 +11,6 @@ import json
from types import SimpleNamespace
from uuid import UUID
import pyplayready.system.pssh as pr_pssh_mod
import pytest
import unshackle.core.cdm as cdm_mod
@@ -27,11 +26,6 @@ KID_B = UUID("43de497c6d1945f49acc2951696ec628")
KID_C = UUID("75982fac2cd8412a990a59c0ef2d4bb1")
class _FakePRPSSH:
def __init__(self, data):
self.data = data
class _FakePlayReady:
def __init__(self, pssh=None, pssh_b64=None, kid=None, **kwargs):
self.kids = [kid] if kid else [KID_A]
@@ -39,6 +33,10 @@ class _FakePlayReady:
self.pssh_b64 = pssh_b64
self.data = {"pssh_b64": pssh_b64} if pssh_b64 else {}
@classmethod
def from_pssh_b64(cls, pssh_b64, kid=None):
return cls(pssh_b64=pssh_b64, kid=kid)
def absorb(self, *others):
for other in others:
if other is self:
@@ -53,7 +51,6 @@ class _FakePlayReady:
@pytest.fixture
def env(monkeypatch):
monkeypatch.setattr(pr_pssh_mod, "PSSH", _FakePRPSSH)
monkeypatch.setattr(drm_mod, "PlayReady", _FakePlayReady)
monkeypatch.setitem(cdm_mod.__dict__, "load_cdm", lambda *a, **k: object())
monkeypatch.setattr(detect_mod, "is_playready_cdm", lambda cdm: True)