fix(remote): keep the server's own CDM when the tier licenses with server_cdm

This commit is contained in:
imSp4rky
2026-09-20 01:19:48 -06:00
parent 025499efa7
commit b8f00f6b95
3 changed files with 18 additions and 2 deletions
+14
View File
@@ -119,3 +119,17 @@ def test_validate_rejects_bad_region_values(accounts):
handlers.config.serve["server_accounts"]["EX"]["ca_main"] = "canada" handlers.config.serve["server_accounts"]["EX"]["ca_main"] = "canada"
with pytest.raises(ValueError): with pytest.raises(ValueError):
handlers.validate_server_accounts() handlers.validate_server_accounts()
def test_server_cdm_ignores_client_cdm_type(monkeypatch):
"""A server_cdm tier licenses with the server's own device, so the client's CDM type must
not swap it for a stub of the other DRM system."""
seen = []
monkeypatch.setattr(handlers, "load_service_yaml", lambda s: {})
monkeypatch.setattr(handlers, "load_full_cdm", lambda s, p, t=None: seen.append(t))
monkeypatch.setattr(handlers.Services, "load", staticmethod(lambda s: object()))
monkeypatch.setattr(handlers, "instantiate_service", lambda *a: "svc")
data = {"cdm_type": "playready"}
handlers.create_service_instance("OTHER", "t", data, None, [], None, server_cdm=True)
handlers.create_service_instance("OTHER", "t", data, None, [], None)
assert seen == [None, "playready"]
+3 -1
View File
@@ -2855,6 +2855,7 @@ def create_service_instance(
proxy_providers: list, proxy_providers: list,
profile: Optional[str], profile: Optional[str],
server_account: bool = False, server_account: bool = False,
server_cdm: bool = False,
) -> Any: ) -> Any:
"""Make a service instance and resolve its credentials and cookies. """Make a service instance and resolve its credentials and cookies.
@@ -2868,7 +2869,7 @@ def create_service_instance(
from unshackle.core.tracks import Video from unshackle.core.tracks import Video
service_config = load_service_yaml(normalized_service) service_config = load_service_yaml(normalized_service)
cdm = load_full_cdm(normalized_service, profile, data.get("cdm_type")) cdm = load_full_cdm(normalized_service, profile, None if server_cdm else data.get("cdm_type"))
# Reconstruct enum track-selection params from client data so service code that reads # Reconstruct enum track-selection params from client data so service code that reads
# ctx.parent.params (Service.__init__ proxy/range/vcodec/best_available block) sees enums. # ctx.parent.params (Service.__init__ proxy/range/vcodec/best_available block) sees enums.
@@ -2987,6 +2988,7 @@ async def session_create_handler(data: Dict[str, Any], request: Optional[web.Req
proxy_providers, proxy_providers,
profile, profile,
server_account=server_account, server_account=server_account,
server_cdm=server_cdm_allowed(request, normalized_service),
) )
service_instance, cookies, credential = await asyncio.to_thread(build_service) service_instance, cookies, credential = await asyncio.to_thread(build_service)
+1 -1
View File
@@ -938,7 +938,7 @@ class RemoteService:
create_data.update(self._service_params) create_data.update(self._service_params)
create_data["service_params"] = self._service_params create_data["service_params"] = self._service_params
cdm = self.ctx.obj.cdm if self.ctx.obj else None cdm = self.ctx.obj.cdm if self.ctx.obj and not self._server_cdm else None
if cdm is not None: if cdm is not None:
from unshackle.core.cdm.detect import is_playready_cdm from unshackle.core.cdm.detect import is_playready_cdm