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
+3 -2
View File
@@ -87,10 +87,11 @@ def drm_from_init_segment(track: Any, session: Any = None, init_data: bytes | No
return drms
def ensure_track_drm(track: Any, session: Any = None, init_data: bytes | None = None) -> None:
def ensure_track_drm(track: Any, session: Any = None, init_data: bytes | None = None, bridge: bool = False) -> None:
"""Fill ``track.drm`` from the manifest when the track has none; a failure leaves it empty and never raises.
Reads DASH ContentProtection and then the init segment, the HLS playlist keys, or the ISM ProtectionHeader.
With ``bridge`` (the service has a FairPlay bridge hook) a FairPlay-only HLS track gets the bridged stubs.
"""
if track.drm:
return
@@ -109,7 +110,7 @@ def ensure_track_drm(track: Any, session: Any = None, init_data: bytes | None =
if (track.data.get("hls") or getattr(track, "descriptor", None) is Track.Descriptor.HLS) and track.url:
try:
if track.load_drm_from_playlist(session, bridge=True):
if track.load_drm_from_playlist(session, bridge=bridge):
return
except Exception as e:
log.debug(f"HLS DRM prefetch failed for {track.id}: {e!r}")