Treat narrators as a distinguishing field to prevent merging different recordings...
authorhayupadhyaya <41875548+hayupadhyaya@users.noreply.github.com>
Tue, 24 Feb 2026 08:17:11 +0000 (03:17 -0500)
committerGitHub <noreply@github.com>
Tue, 24 Feb 2026 08:17:11 +0000 (09:17 +0100)
fix(audiobooks): treat narrators as a distinguishing field to prevent merging different recordings

Audiobooks with the same title and author but different narrators
(e.g. the same Harry Potter title read by Stephen Fry and Jim Dale)
were being merged into a single library item. This caused:
- Only one narrator to be retained in the merged item
- Chapter lists from all recordings to be concatenated, producing
  incorrect (doubled) chapter counts
- No way for clients to retrieve per-recording metadata via the API

Fix: in compare_audiobook(), add a narrator check before the author
comparison. When both items have narrators and no narrators are shared,
return False so they are treated as distinct recordings.

This change is safe for the single-narrator case: if either item has no
narrator metadata, the check is skipped and existing behaviour is
unchanged.

Co-authored-by: hayupadhyaya <hayupadhyaya@users.noreply.github.com>
music_assistant/helpers/compare.py

index c03d064860af34fa5333f72f7bd7a42bd300206c..a4a51ca04bf30c8f10d5db4ca13526b3a17d2561 100644 (file)
@@ -319,6 +319,12 @@ def compare_audiobook(
         and not compare_strings(base_item.publisher, compare_item.publisher, strict=True)
     ):
         return False
+    # compare narrator(s) — different narrators indicate different recordings and must not be merged
+    if base_item.narrators and compare_item.narrators:
+        base_narrators = {create_safe_string(n) for n in base_item.narrators}
+        compare_narrators = {create_safe_string(n) for n in compare_item.narrators}
+        if base_narrators.isdisjoint(compare_narrators):
+            return False
     # compare author(s)
     for author in base_item.authors:
         author_safe = create_safe_string(author)