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
+6 -6
View File
@@ -44,7 +44,7 @@ from unshackle.core.config import config
from unshackle.core.console import SyncLive, console
from unshackle.core.constants import AnyTrack, DownloadCancelled, RunCancel
from unshackle.core.credential import Credential
from unshackle.core.drm import MonaLisa, cbcs, real_kids
from unshackle.core.drm import CustomDRM, cbcs, real_kids
from unshackle.core.drm.cenc import PLACEHOLDER_KIDS
from unshackle.core.drm.discovery import track_pssh
from unshackle.core.launch import launch_keys
@@ -1625,7 +1625,7 @@ class RemoteService(TitleSource):
media playlist names the DRM and the downloader honours ``drm_preference``. On the server's device
there is no such licence: the error names ``kid``, else each KID of ``drm`` with no content key.
"""
from unshackle.core.cdm.detect import cdm_system, is_playready_cdm
from unshackle.core.cdm.detect import cdm_label, cdm_system
if refusal.get("reason") == "server_device":
vaults = (
@@ -1659,7 +1659,7 @@ class RemoteService(TitleSource):
raise coded(
click.ClickException(f"{why}, and {track} needs a local CDM to license it"), APIErrorCode.DRM_ERROR
)
drm_class = "PlayReady" if is_playready_cdm(cdm) else "Widevine"
drm_class = cdm_label(cdm)
height = getattr(track, "height", None)
systems = {d.__class__.__name__ for d in track.drm or ()}
if systems and drm_class not in systems:
@@ -1779,7 +1779,7 @@ class RemoteService(TitleSource):
"""The content keys the server CDM licenses for ``drm`` of ``track``, or None when the server hands it to this machine.
The request sends the header of ``drm`` when it is of a system the server licenses, as a playlist can name a
KID that ``track.drm`` does not hold; a MonaLisa request sends no header, as the server holds the DRM its
KID that ``track.drm`` does not hold; a plugin DRM request sends no header, as the server holds the DRM its
service built. ``kid`` is the KID the server CDM must answer; a content key for it
from a server vault stands in for the licence. A failed request logs one warning and returns no keys.
"""
@@ -1788,8 +1788,8 @@ class RemoteService(TitleSource):
if deferred := self.deferred_refusals.get(str(track.id)):
raise click.ClickException(deferred)
server_type = self.server_cdm_type
if isinstance(drm, MonaLisa):
request = LicenseRequest(drm_type="monalisa", mode="server_cdm")
if isinstance(drm, CustomDRM):
request = LicenseRequest(drm_type=drm.plugin_id, mode="server_cdm")
else:
other_type = "playready" if server_type == "widevine" else "widevine"
drm_type, pssh_b64 = server_type, track_pssh(track, server_type, drm)