refactor(api): dedup handler serializers, validation, and service setup

Collapse repeated serializer/validation/CDM/list-setup logic in handlers.py behind small helpers; output behaviour unchanged.
This commit is contained in:
imSp4rky
2026-06-21 13:23:22 -06:00
parent 8a9a1e1bdc
commit fb90cd87b0
2 changed files with 152 additions and 265 deletions
@@ -199,6 +199,22 @@ def test_serialize_drm_widevine_minimal() -> None:
assert info["license_url"] == "https://lic.example.com/wv"
def test_serialize_drm_playready_pssh_without_dumps_is_omitted() -> None:
# pyplayready's PSSH exposes no dumps()/to_base64()/__bytes__; serialization
# must omit the pssh field rather than emit an object repr.
class _PSSH:
pass
class _PlayReady:
def __init__(self) -> None:
self._pssh = _PSSH()
self.kids = ["00112233445566778899aabbccddeeff"]
info = serialize_drm(_PlayReady())[0]
assert "pssh" not in info
assert info["kids"] == ["00112233445566778899aabbccddeeff"]
# ---------- validate_service ----------