mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-27 03:15:08 +00:00
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:
@@ -41,7 +41,7 @@ from rich.tree import Tree
|
|||||||
|
|
||||||
from unshackle.core import binaries, providers
|
from unshackle.core import binaries, providers
|
||||||
from unshackle.core.cdm import DecryptLabsRemoteCDM
|
from unshackle.core.cdm import DecryptLabsRemoteCDM
|
||||||
from unshackle.core.cdm.detect import is_playready_cdm, is_widevine_cdm
|
from unshackle.core.cdm.detect import cdm_type_stub, is_playready_cdm, is_widevine_cdm
|
||||||
from unshackle.core.config import config, resolve_cdm_name, resolve_decryption
|
from unshackle.core.config import config, resolve_cdm_name, resolve_decryption
|
||||||
from unshackle.core.console import GradientPulseBarColumn, SyncLive, console, listing_panel
|
from unshackle.core.console import GradientPulseBarColumn, SyncLive, console, listing_panel
|
||||||
from unshackle.core.constants import DOWNLOAD_CANCELLED, DOWNLOAD_LICENCE_ONLY, AnyTrack, context_settings
|
from unshackle.core.constants import DOWNLOAD_CANCELLED, DOWNLOAD_LICENCE_ONLY, AnyTrack, context_settings
|
||||||
@@ -2843,6 +2843,11 @@ class dl:
|
|||||||
download_table = Table.grid()
|
download_table = Table.grid()
|
||||||
download_table.add_row(selected_tracks)
|
download_table.add_row(selected_tracks)
|
||||||
|
|
||||||
|
if getattr(self._remote_service, "_server_cdm", False) and self.cdm is None:
|
||||||
|
cdm_type = getattr(self._remote_service, "_server_cdm_type", "widevine")
|
||||||
|
self.cdm = cdm_type_stub(cdm_type)
|
||||||
|
self.log.info(f"Using server CDM ({cdm_type.title()}); no local CDM required")
|
||||||
|
|
||||||
video_tracks = title.tracks.videos
|
video_tracks = title.tracks.videos
|
||||||
if video_tracks:
|
if video_tracks:
|
||||||
highest_quality = max((track.height for track in video_tracks if track.height), default=0)
|
highest_quality = max((track.height for track in video_tracks if track.height), default=0)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from datetime import date as date_
|
from datetime import date as date_
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import SimpleNamespace
|
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from aiohttp import web
|
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_log import SessionLogBuffer, SessionLogMirror, capture_service_logs
|
||||||
from unshackle.core.api.session_store import SessionStore
|
from unshackle.core.api.session_store import SessionStore
|
||||||
from unshackle.core.cacher import Cacher
|
from unshackle.core.cacher import Cacher
|
||||||
|
from unshackle.core.cdm.detect import cdm_type_stub
|
||||||
from unshackle.core.config import config
|
from unshackle.core.config import config
|
||||||
from unshackle.core.constants import AUDIO_CODEC_MAP, DYNAMIC_RANGE_MAP, VIDEO_CODEC_MAP
|
from unshackle.core.constants import AUDIO_CODEC_MAP, DYNAMIC_RANGE_MAP, VIDEO_CODEC_MAP
|
||||||
from unshackle.core.providers.anilist import parse_anilist_ref
|
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]:
|
def resolve_server_cdm(service: str, profile: Optional[str], cdm_type: Optional[str]) -> Optional[Any]:
|
||||||
"""Get the CDM for the server context.
|
"""Get the CDM for the server context.
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from types import SimpleNamespace
|
||||||
from typing import Any
|
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:
|
def is_remote_cdm(cdm: Any) -> bool:
|
||||||
"""
|
"""
|
||||||
Return True if a remote CDM or a service CDM backs the CDM instance.
|
Return True if a remote CDM or a service CDM backs the CDM instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user