From ba819aa11ea17edddaac92a31b7e6c0800a83a12 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Wed, 23 Sep 2026 11:19:26 -0600 Subject: [PATCH] fix(export): strip session headers from exports and normalise merged keys --- tests/core/test_import_hls_ism.py | 2 +- unshackle/commands/dl.py | 4 ++-- uv.lock | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/core/test_import_hls_ism.py b/tests/core/test_import_hls_ism.py index 752ec527..e919be75 100644 --- a/tests/core/test_import_hls_ism.py +++ b/tests/core/test_import_hls_ism.py @@ -123,7 +123,7 @@ def test_encrypted_ism_rung_gets_the_exported_keys(tmp_path: Path, monkeypatch: export = export_tracks(tmp_path, parsed, ISM_URL) doc = json.loads(export.read_text(encoding="utf8")) - doc["titles"][0]["keys"] = {"0" * 32: "ab" * 16} + doc["titles"][0]["keys"] = {"1" * 32: "ab" * 16} doc["titles"][0]["drm"] = [{"system": "playready"}] export.write_text(json.dumps(doc), encoding="utf8") diff --git a/unshackle/commands/dl.py b/unshackle/commands/dl.py index 2351c52a..a186f912 100644 --- a/unshackle/commands/dl.py +++ b/unshackle/commands/dl.py @@ -3983,12 +3983,12 @@ class dl: for kid, key in content_keys.items(): # a KID that already holds a different key must not be overwritten: # the reader rejects a file that disagrees with itself - if pool.setdefault(kid.hex, key) != key: + if pool.setdefault(kid.hex, key.lower()) != key.lower(): self.log.warning( f"KID {kid.hex} already has a different key in {export}, keeping the existing one" ) else: - entry.keys[kid.hex] = key + entry.add_key(kid.hex, key) mediaexport.write(export, doc) diff --git a/uv.lock b/uv.lock index bef65c90..247a6db0 100644 --- a/uv.lock +++ b/uv.lock @@ -1077,7 +1077,7 @@ wheels = [ [[package]] name = "mediaexport" version = "0.1.0" -source = { git = "https://github.com/unshackle-dl/mediaexport?branch=main#07893237199fc865bd5c63b6848235e4f6ef81c8" } +source = { git = "https://github.com/unshackle-dl/mediaexport?branch=main#144edd7bcaa943ad0a5116c998734d9f24c41aae" } [[package]] name = "more-itertools"