diff --git a/tests/core/test_export.py b/tests/core/test_export.py index 286ae213..89f0d350 100644 --- a/tests/core/test_export.py +++ b/tests/core/test_export.py @@ -293,6 +293,17 @@ def test_import_with_no_usable_title_says_so(tmp_path: Path) -> None: ImportService(import_ctx(), "EXAMPLE", "movie-1", str(export)) +@pytest.mark.parametrize(("system", "expected"), [("playready", "playready"), ("widevine", "widevine")]) +def test_import_takes_its_drm_type_from_the_export(tmp_path: Path, system: str, expected: str) -> None: + """The type stub routes the DRM objects, so it follows the exported system, not a widevine default.""" + export = crit_export(tmp_path / "export.json") + doc = read_export(export) + doc["titles"][0]["drm"] = [{"system": system, "pssh": "AAAA"}] + export.write_text(json.dumps(doc), encoding="utf8") + + assert ImportService(import_ctx(), "EXAMPLE", "movie-1", str(export))._server_cdm_type == expected + + class KeyDRM: """A licensed DRM system that holds only ``content_keys``.""" diff --git a/unshackle/commands/dl.py b/unshackle/commands/dl.py index 8edf2c09..eb0abe93 100644 --- a/unshackle/commands/dl.py +++ b/unshackle/commands/dl.py @@ -2935,7 +2935,12 @@ class dl: if getattr(self._remote_service, "_server_cdm", False): server_cdm_type = getattr(self._remote_service, "_server_cdm_type", "widevine") self.cdm = cdm_type_stub(server_cdm_type) - self.log.info(f"Using server CDM ({server_cdm_type.title()}); no local CDM required") + from unshackle.core.import_service import ImportService + + if isinstance(self._remote_service, ImportService): + self.log.info("Using keys from the export; no CDM required") + else: + self.log.info(f"Using server CDM ({server_cdm_type.title()}); no local CDM required") video_tracks = title.tracks.videos if video_tracks and not server_cdm_type: diff --git a/unshackle/core/import_service.py b/unshackle/core/import_service.py index 1b1aefc4..21ec341c 100644 --- a/unshackle/core/import_service.py +++ b/unshackle/core/import_service.py @@ -173,7 +173,7 @@ class ImportService: self.tracks_by_title: dict[str, Tracks] = {} self._server_cdm = True - self._server_cdm_type = "widevine" + self._server_cdm_type = "playready" if self.exported_drm_system() == "playready" else "widevine" first = self.doc.titles[0] # a title with no manifest keeps its request headers on its file rows