Skip to content

Prefer English edition in ratings-based edition selection tiebreak - #142

Open
jbob06 wants to merge 1 commit into
Chaptarr:developfrom
jbob06:fix/edition-language-preference-tiebreak
Open

jbob06 wants to merge 1 commit into
Chaptarr:developfrom
jbob06:fix/edition-language-preference-tiebreak

Conversation

@jbob06

@jbob06 jbob06 commented Sep 14, 2026

Copy link
Copy Markdown

Bug

When an import list discovers a new author from one shelved book, Chaptarr pulls in that author's entire back-catalog as unmonitored stub Book rows. For each work, EditionSelector has to pick one edition to represent it in the local catalog — and that pick had no language preference at all: it ranked candidates purely by native-format match, then per-edition vote count.

MetadataProfile.AllowedLanguages only filters the candidate pool when it's explicitly configured. On the common unconfigured profile, every language passes through untouched, and a translated edition can end up with more votes on its own edition row than the original English one for the same work (e.g. all Spanish-reader votes on one edition row, while English votes are split across several English edition rows). The higher-voted foreign edition then wins and gets stored as the book's sole representative edition.

Concretely, this produced local catalog rows like:

  • A book whose local title became "<Title> [Spanish Edition]", its stored edition carrying Spanish narrator credits, despite an English edition of the same work being available
  • A book whose local title became "<Title> – <German subtitle>", similarly mismatched

Both cases trace to the same author-bibliography-refresh timestamp in the DB, confirming the bulk back-catalog path, not a one-off manual add.

This selector (EditionSelector.SelectByNativeFormatThenRatings, via SelectMostRated/SelectRepresentativeFallback) is shared by two call sites:

  • BookInfoProxy.SelectBestEditionAsMonitored — the provisional pick made when converting an author's full back-catalog from provider data, explicitly commented as provisional ("Language ... filtering happen[s] later once the metadata profile is available")
  • AuthorLibraryService.SelectMonitoredEditionsForMediaType — the later, profile-aware pick

Unmonitored bibliography stub books never get promoted to the second pass, so they stay stuck with whatever the language-blind provisional pick chose — permanently.

Fix

Add a language-preference tiebreak ahead of vote count in SelectMostRated and SelectRepresentativeFallback: an edition with explicit English language wins, an edition with no language tag is treated neutrally (not punished for missing metadata), and any other explicit language loses. It's a soft default ordering key, not an exclusionary filter — a foreign-only candidate pool still falls back to picking by votes exactly as before, and a library where AllowedLanguages is explicitly restricted to something else still narrows correctly upstream in EditionMetadataProfileFilter.

Added tests in EditionSelectorLanguageFilteringFixture covering: English winning over a more-voted foreign edition for both audiobook and ebook media types, and the no-English-available fallback still picking by votes.

Testing

Ran dotnet test (net10.0) locally: full suite passes, 3023/3023, 0 failures — including the 3 new tests in EditionSelectorLanguageFilteringFixture.

🤖 Generated with Claude Code

EditionSelector.SelectMostRated and SelectRepresentativeFallback picked
purely by native-format match then per-edition vote count, with no
language awareness. MetadataProfile.AllowedLanguages only filters
candidates when explicitly configured, so on the common unconfigured
profile every language passes through untouched, and a translated
edition with more votes on its own edition row can outrank the
original English one for the same work. This selector is shared by
both the provisional pick made when an author's full back-catalog is
first converted from provider data (BookInfoProxy) and the final pick
made once a metadata profile is available (AuthorLibraryService) -
unmonitored bibliography stub books never get re-picked after the
provisional pass, so they stay mislabeled with the foreign edition's
title/narrators permanently.

Add a language-preference tiebreak ahead of votes: explicit English
wins, unset/unknown language is treated neutrally (an edition missing
a language tag isn't punished), any other explicit language loses.
This only reorders within an already-filtered candidate pool, so a
library-wide non-English AllowedLanguages restriction still narrows
correctly upstream, and a foreign-only candidate pool still falls back
to picking by votes exactly as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant