fix(api): let a core failure name its own API error code

This commit is contained in:
imSp4rky
2026-11-25 15:43:14 -07:00
parent e4ba7c2908
commit fcda47d995
23 changed files with 453 additions and 151 deletions
+4 -1
View File
@@ -84,6 +84,7 @@ from unshackle.core.remote_protocol import (
TrackKeys,
TracksReply,
TracksRequest,
coded,
)
from unshackle.core.search_result import SearchResult
from unshackle.core.session import MAX_BACKOFF
@@ -1680,7 +1681,9 @@ class RemoteService:
why = "The server CDM refused this track"
cdm = self.local_cdm
if cdm is None:
raise click.ClickException(f"{why}, and {track} needs a local CDM to license it")
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"
height = getattr(track, "height", None)
systems = {d.__class__.__name__ for d in track.drm or ()}