From 70c3a055529d132ac6a7c0c7935ab15f3388e1d6 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Sat, 12 Sep 2026 20:30:56 -0600 Subject: [PATCH] fix(import): inject only the imported title's keys into each track --- unshackle/core/import_service.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/unshackle/core/import_service.py b/unshackle/core/import_service.py index e3cc7f26..9494fb62 100644 --- a/unshackle/core/import_service.py +++ b/unshackle/core/import_service.py @@ -305,10 +305,11 @@ class ImportService: self.tracks_by_title[title_id] = tracks return tracks - def key_pool(self) -> dict[UUID, str]: - """All exported KID:KEY pairs across every title, as {UUID: key_hex}.""" + def key_pool(self, title_id: Optional[str] = None) -> dict[UUID, str]: + """Exported KID:KEY pairs as {UUID: key_hex}, for one title or across every title.""" pool: dict[UUID, str] = {} - for entry in self.titles_data.values(): + entries = [self.titles_data.get(title_id, {})] if title_id else self.titles_data.values() + for entry in entries: for track_dict in (entry.get("tracks") or {}).values(): for kid_hex, key in (track_dict.get("keys") or {}).items(): pool[UUID(hex=kid_hex)] = key @@ -347,7 +348,7 @@ class ImportService: which DASH.download_track preserves. decrypt() applies the content key whose KID matches the media. """ - pool = self.key_pool() + pool = self.key_pool(str(title.id)) or self.key_pool() if not pool: return