From 96411e5d7d4201f330a059bac35ff5af4cadbbcb Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 7 Feb 2026 19:44:23 -0700 Subject: [PATCH] fix(hls): keep range offset numeric and align MonaLisa licensing - Parse init section byterange offset as int to avoid string arithmetic bugs - Wrap MonaLisa licensing in the same progress + error handling flow as Widevine/PlayReady --- unshackle/core/manifests/hls.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/unshackle/core/manifests/hls.py b/unshackle/core/manifests/hls.py index cabd13d..539e3f3 100644 --- a/unshackle/core/manifests/hls.py +++ b/unshackle/core/manifests/hls.py @@ -350,8 +350,16 @@ class HLS: raise if not initial_drm_licensed and session_drm and isinstance(session_drm, MonaLisa): - if license_widevine: + try: + if not license_widevine: + raise ValueError("license_widevine func must be supplied to use DRM") + progress(downloaded="LICENSING") license_widevine(session_drm) + progress(downloaded="[yellow]LICENSED") + except Exception: # noqa + DOWNLOAD_CANCELLED.set() # skip pending track downloads + progress(downloaded="[red]FAILED") + raise if DOWNLOAD_LICENCE_ONLY.is_set(): progress(downloaded="[yellow]SKIPPED") @@ -608,7 +616,7 @@ class HLS: if segment.init_section and (not map_data or segment.init_section != map_data[0]): if segment.init_section.byterange: init_byte_range = HLS.calculate_byte_range(segment.init_section.byterange, range_offset) - range_offset = init_byte_range.split("-")[0] + range_offset = int(init_byte_range.split("-")[0]) init_range_header = {"Range": f"bytes={init_byte_range}"} else: init_range_header = {}