Use the session DRM as the initial DRM for HLS

The variant-playlist may have DRM information that won't be in the invariant (stream) playlist. We need to begin with this DRM data if available.
This commit is contained in:
rlaphoenix 2023-02-22 04:30:24 +00:00
parent c1f716cb6c
commit 2ad3f04a5e
1 changed files with 14 additions and 3 deletions

View File

@ -299,11 +299,22 @@ class HLS:
if callable(track.OnDecrypted):
track.OnDecrypted(track)
init_data = Queue(maxsize=1)
segment_key = Queue(maxsize=1)
# otherwise will be stuck waiting on the first pool, forever
init_data = Queue(maxsize=1)
if track.drm:
session_drm = track.drm[0] # just use the first supported DRM system for now
if isinstance(session_drm, Widevine):
# license and grab content keys
if not license_widevine:
raise ValueError("license_widevine func must be supplied to use Widevine DRM")
license_widevine(session_drm)
else:
session_drm = None
# have data to begin with, or it will be stuck waiting on the first pool forever
segment_key.put((session_drm, None))
init_data.put(None)
segment_key.put((None, None))
with tqdm(total=len(master.segments), unit="segments") as pbar:
with ThreadPoolExecutor(max_workers=16) as pool: