refactor(drm): move track drm discovery into core and merge the drifted pssh and hls playlist readers

This commit is contained in:
imSp4rky
2026-11-26 13:40:06 -07:00
parent 136e9fc84d
commit 3c90346ae4
18 changed files with 260 additions and 206 deletions
+1 -11
View File
@@ -46,6 +46,7 @@ from unshackle.core.credential import Credential
from unshackle.core.dl_options import remote_dl_params
from unshackle.core.drm import cbcs, real_kids
from unshackle.core.drm.cenc import 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, restore
from unshackle.core.proxies.resolve import is_loopback
@@ -412,17 +413,6 @@ def sample_batches(samples: list[bytes]) -> Iterator[list[bytes]]:
yield batch
def track_pssh(track: Any, drm_type: str, drm: Any = None) -> str | None:
"""The base64 PSSH of one DRM system's header: ``drm``'s own when it is of that system, else the track's first."""
for drm_obj in [drm, *(track.drm or [])]:
drm_class = drm_obj.__class__.__name__
if drm_type == "playready" and drm_class == "PlayReady":
return drm_obj.data["pssh_b64"]
if drm_type == "widevine" and drm_class == "Widevine":
return drm_obj.pssh.dumps()
return None
def apply_service_track_data(tracks: Tracks, data: dict[str, Any]) -> None:
"""Overlay the service-set ``track.data`` the server sent.