feat(remote): spoof a type-only CDM so server_cdm clients need no local .wvd/.prd

Stand in a SimpleNamespace CDM matching the server's DRM system when server_cdm is active and no local device is loaded, guarded on the resolved _server_cdm. Centralizes cdm_type_stub in cdm.detect, reused by the REST handlers.
This commit is contained in:
imSp4rky
2026-08-31 22:15:47 -06:00
parent 006a7c2ef0
commit 5670f610aa
3 changed files with 15 additions and 8 deletions
+1 -7
View File
@@ -6,7 +6,6 @@ import logging
import re
from datetime import date as date_
from pathlib import Path
from types import SimpleNamespace
from typing import Any, Dict, List, Optional
from aiohttp import web
@@ -18,6 +17,7 @@ from unshackle.core.api.sanitize import safe_cache_key, sanitize_log
from unshackle.core.api.session_log import SessionLogBuffer, SessionLogMirror, capture_service_logs
from unshackle.core.api.session_store import SessionStore
from unshackle.core.cacher import Cacher
from unshackle.core.cdm.detect import cdm_type_stub
from unshackle.core.config import config
from unshackle.core.constants import AUDIO_CODEC_MAP, DYNAMIC_RANGE_MAP, VIDEO_CODEC_MAP
from unshackle.core.providers.anilist import parse_anilist_ref
@@ -2739,12 +2739,6 @@ async def session_segments_handler(
)
def cdm_type_stub(cdm_type: str) -> SimpleNamespace:
"""Lightweight CDM stand-in so ``is_playready_cdm()`` (reads ``.is_playready``)
can detect the type without loading a full CDM."""
return SimpleNamespace(is_playready=cdm_type == "playready")
def resolve_server_cdm(service: str, profile: Optional[str], cdm_type: Optional[str]) -> Optional[Any]:
"""Get the CDM for the server context.
+8
View File
@@ -1,8 +1,16 @@
from __future__ import annotations
from types import SimpleNamespace
from typing import Any
def cdm_type_stub(cdm_type: str) -> SimpleNamespace:
"""Type-only CDM stand-in so is_widevine_cdm()/is_playready_cdm() (and thus
get_drm_for_cdm) route correctly without loading a real device. Used for
server_cdm mode, where the server holds the device and returns the keys."""
return SimpleNamespace(is_playready=cdm_type == "playready")
def is_remote_cdm(cdm: Any) -> bool:
"""
Return True if a remote CDM or a service CDM backs the CDM instance.