feat(drm)!: load DRM systems beyond the built-ins from plugins in directories.plugins

This commit is contained in:
imSp4rky
2026-12-03 15:51:42 -07:00
parent f8a248a29e
commit e9adc50594
65 changed files with 1651 additions and 2526 deletions
+7 -3
View File
@@ -17,7 +17,7 @@ from tests.remote.key_source import MemoryKeySource, remote_keys
from unshackle.commands import dl as dl_module
from unshackle.core.config import config
from unshackle.core.credential import Credential
from unshackle.core.drm import BlowfishStripe, ClearKeyCTR, PlayReady, Widevine
from unshackle.core.drm import ClearKeyCTR, CustomDRM, PlayReady, Widevine
from unshackle.core.drm.cenc import drm_stub
from unshackle.core.import_service import ImportService
from unshackle.core.service import Service
@@ -262,7 +262,7 @@ def ctr() -> ClearKeyCTR:
[
({"v": [ctr()], "a": [ctr()]}, "widevine", "Using keys from the server; no local CDM required"),
(
{"v": [BlowfishStripe(key=bytes(8))], "a": [ctr()]},
{"v": ["held-plugin"], "a": [ctr()]},
"playready",
"Using keys from the server; no local CDM required",
),
@@ -273,16 +273,20 @@ def ctr() -> ClearKeyCTR:
"Using server CDM (Widevine); no local CDM required",
),
({"v": [drm_stub("playready", KIDS)]}, "playready", "Using server CDM (PlayReady); no local CDM required"),
({"a": [ctr()]}, "example", "Using server CDM (EXAMPLE); no local CDM required"),
],
ids=["whole-file", "whole-file-playready-server", "video-drm-not-loaded", "mixed", "playready"],
ids=["whole-file", "whole-file-playready-server", "video-drm-not-loaded", "mixed", "playready", "plugin"],
)
def test_dl_names_the_server_cdm_only_for_a_title_that_needs_one(
monkeypatch: pytest.MonkeyPatch,
caplog: pytest.LogCaptureFixture,
example_plugins: None,
drm: dict[str, Any],
server_cdm_type: str,
line: str,
) -> None:
held = CustomDRM("other", data={"key": bytes(8).hex()})
drm = {kind: [held if d == "held-plugin" else d for d in drms] for kind, drms in drm.items()}
lines: list[str] = []
monkeypatch.setattr(logging.getLogger("test_kind_only"), "info", lambda msg, *a, **k: lines.append(msg))
monkeypatch.setattr(dl_module.login, "save_cookies", lambda *a: None)