mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 15:35:06 +00:00
feat(remote): name the missing KID in the server-device error
This commit is contained in:
@@ -47,7 +47,7 @@ from unshackle.core.constants import AnyTrack
|
||||
from unshackle.core.credential import Credential
|
||||
from unshackle.core.dl_options import remote_dl_params
|
||||
from unshackle.core.drm import cbcs, real_kids, whole_file_cipher
|
||||
from unshackle.core.drm.cenc import drm_stub
|
||||
from unshackle.core.drm.cenc import PLACEHOLDER_KIDS, drm_stub
|
||||
from unshackle.core.drm.discovery import track_pssh
|
||||
from unshackle.core.launch import launch_keys
|
||||
from unshackle.core.manifests.snapshot import match_track
|
||||
@@ -1574,11 +1574,14 @@ class RemoteService(TitleSource):
|
||||
self.deferred_refusals[str(track.id)] = e.message
|
||||
self.log.debug(f"{e.message}; trying the local vaults first")
|
||||
|
||||
def license_locally(self, track: AnyTrack, refusal: dict[str, Any]) -> None:
|
||||
def license_locally(
|
||||
self, track: AnyTrack, refusal: dict[str, Any], drm: Any = None, kid: UUID | None = None
|
||||
) -> None:
|
||||
"""Hand a track the server CDM refused to license live to this machine's own device.
|
||||
|
||||
dl then licenses it through the challenge relay. An HLS track with no DRM yet passes, as its
|
||||
media playlist names the DRM and the downloader honours ``drm_preference``.
|
||||
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
|
||||
|
||||
@@ -1588,8 +1591,19 @@ class RemoteService(TitleSource):
|
||||
if self.local_vaults_only
|
||||
else "no vault, neither the server's nor yours"
|
||||
)
|
||||
raise click.ClickException(
|
||||
f"The content key for {track} is in {vaults}; drop the service's server-identity option to license it locally"
|
||||
if kid and kid not in PLACEHOLDER_KIDS:
|
||||
kids = [kid.hex]
|
||||
else:
|
||||
drms: Iterable[Any] = [drm] if drm is not None else track.drm or []
|
||||
kids = sorted({k.hex for d in drms for k in real_kids(d) if k not in d.content_keys})
|
||||
article = "A" if len(kids) > 1 else "The"
|
||||
of_kid = f" of KID {', '.join(kids)}" if kids else ""
|
||||
raise coded(
|
||||
click.ClickException(
|
||||
f"{article} content key{of_kid} for {track} is in {vaults}; "
|
||||
"drop the service's server-identity option to license it locally"
|
||||
),
|
||||
APIErrorCode.DRM_ERROR,
|
||||
)
|
||||
cap = refusal.get("max_height")
|
||||
if cap:
|
||||
@@ -1721,7 +1735,7 @@ class RemoteService(TitleSource):
|
||||
from a server vault stands in for the licence. A failed request logs one warning and returns no keys.
|
||||
"""
|
||||
if self.local_vaults_only:
|
||||
self.license_locally(track, {"reason": "server_device"})
|
||||
self.license_locally(track, {"reason": "server_device"}, drm, kid)
|
||||
if deferred := self.deferred_refusals.get(str(track.id)):
|
||||
raise click.ClickException(deferred)
|
||||
server_type = self.server_cdm_type
|
||||
@@ -1752,7 +1766,7 @@ class RemoteService(TitleSource):
|
||||
except (Exception, RemoteError) as e:
|
||||
self.log.warning("server_cdm license failed: %s", e)
|
||||
return {}
|
||||
self.license_locally(track, resp.get("details") or {})
|
||||
self.license_locally(track, resp.get("details") or {}, drm, kid)
|
||||
return None
|
||||
|
||||
def license_file(self, track: AnyTrack) -> str:
|
||||
|
||||
Reference in New Issue
Block a user