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 pywidevine.pssh as wv_pssh_mod
@@ -31,11 +30,6 @@ OTHER = UUID("43de497c6d1945f49acc2951696ec628") # a sibling track's KID from t
PSSH_B64 = base64.b64encode(b"pssh").decode()
class _FakePRPSSH:
def __init__(self, data):
self.data = data
class _FakePlayReady:
"""PSSH reports one KID; the license returns the full multi-key bundle."""
@@ -44,13 +38,16 @@ class _FakePlayReady:
self.content_keys: dict = {}
self.pssh_b64 = pssh_b64
@classmethod
def from_pssh_b64(cls, pssh_b64, kid=None):
return cls(pssh_b64=pssh_b64)
def get_content_keys(self, cdm, certificate, licence):
self.content_keys = {REAL: "k_real", PSSH_KID: "k_pssh", OTHER: "k_other"}
@pytest.fixture
def playready_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)