feat(drm): bridge a FairPlay-only HLS track only for a service with get_fairplay_bridge_license

This commit is contained in:
imSp4rky
2026-12-01 21:07:26 -07:00
parent e36236d5cc
commit 2097d31a0a
38 changed files with 607 additions and 77 deletions
+21 -1
View File
@@ -223,6 +223,14 @@ class TitleSource(metaclass=ABCMeta):
"""
return None
def fairplay_bridge(self) -> Callable[..., Any] | None:
"""The service's ``get_fairplay_bridge_license``, or None: only a service with it gets FairPlay-only tracks bridged.
The hook gets a PlayReady or Widevine challenge for the key IDs of the init segments, with ``challenge``,
``title``, ``track``, ``drm_system`` and the extras of that system's licence callback.
"""
return getattr(self, "get_fairplay_bridge_license", None)
@abstractmethod
def get_titles(self) -> Titles_T:
"""The titles of the title ID."""
@@ -312,4 +320,16 @@ class TitleSource(metaclass=ABCMeta):
"""
__all__ = ("CacheIdentity", "KeyArrival", "ServerKeySource", "TitleSource")
def service_licence(source: TitleSource, drm_system: str, **kwargs: Any) -> Any:
"""Call the licence callback of ``source`` for a ``drm_system`` challenge, with the ``kwargs`` it declares.
A track with a bridged stub goes to ``source.fairplay_bridge()`` with ``drm_system``; any other track goes to
``get_playready_license`` or ``get_widevine_license``.
"""
bridged = any(getattr(drm, "bridged", False) for drm in getattr(kwargs.get("track"), "drm", None) or [])
hook = source.fairplay_bridge() if bridged else None
fn = hook or (source.get_playready_license if drm_system == "playready" else source.get_widevine_license)
return fn(**declared_kwargs(fn, {**kwargs, "drm_system": drm_system} if hook else kwargs))
__all__ = ("CacheIdentity", "KeyArrival", "ServerKeySource", "TitleSource", "service_licence")