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
@@ -14,7 +14,6 @@ from types import SimpleNamespace
from typing import Any
from uuid import UUID
import pyplayready.system.pssh as pr_pssh_mod
import pytest
import pywidevine.pssh as wv_pssh_mod
@@ -113,6 +112,10 @@ class StubPlayReady(PlayReady):
self._refused_headers: set[str] = set()
self.content_keys: dict[UUID, str] = {}
@classmethod
def from_pssh_b64(cls, pssh_b64: str, kid: UUID | None = None) -> StubPlayReady:
return cls(pssh_b64=pssh_b64)
def extract_keys_from_cdm(self, cdm: Any, session_id: Any) -> dict[UUID, str]:
return {KID: KEY.hex()}
@@ -166,7 +169,6 @@ def widevine_env(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.fixture
def playready_env(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(pr_pssh_mod, "PSSH", lambda data: SimpleNamespace(data=data))
monkeypatch.setattr(drm_mod, "PlayReady", StubPlayReady)
monkeypatch.setitem(cdm_mod.__dict__, "load_cdm", lambda *a, **k: FakePlayReadyCdm())
monkeypatch.setattr(detect_mod, "is_playready_cdm", lambda cdm: True)