From b157bb72cee1164bf8515418a00095e2660b1ec1 Mon Sep 17 00:00:00 2001 From: TheMightyTRexUK <196487809+TheMightyTRex@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:12:59 +0000 Subject: [PATCH] Recognise "Series by" and "Books 1 to 5" names as collections Automatic selection keeps series packs away from single book requests by matching release names against PACK, which only knew a numbered range written with a dash ("Books 1-5"). Names such as "The Long Earth Series By Stephen Baxter and Terry Pratchett" or "The Long Earth series, books 1 to 5" were taken for one book, so an automatic grab could pick a whole pack. Match "series by" and numbered ranges written with "to" as well. Co-Authored-By: Claude Opus 5.5 --- services/app/domain/automatic_eligibility.py | 4 ++-- tests/unit/test_pack_coverage.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/services/app/domain/automatic_eligibility.py b/services/app/domain/automatic_eligibility.py index 46e7bc99..56540a2d 100644 --- a/services/app/domain/automatic_eligibility.py +++ b/services/app/domain/automatic_eligibility.py @@ -17,8 +17,8 @@ PARTIAL = re.compile(r"\b(?:sample|excerpt|preview|incomplete|truncated)\d*\b", re.I) DISC_FOLDER = re.compile(r"(?:^|[\s_(\[])(?:cd|disc|disk|part)\s*\d+\b", re.I) PACK = re.compile( - r"\b(collection|pack|omnibus|box[ -]?set|anthology|complete series|" - r"books?\s+\d+\s*[-–]\s*\d+)\b", + r"\b(collection|pack|omnibus|box[ -]?set|anthology|complete series|series by|" + r"books?\s+\d+\s*(?:[-–]|to)\s*\d+)\b", re.I, ) diff --git a/tests/unit/test_pack_coverage.py b/tests/unit/test_pack_coverage.py index 6e47508d..7964c960 100644 --- a/tests/unit/test_pack_coverage.py +++ b/tests/unit/test_pack_coverage.py @@ -263,3 +263,18 @@ def test_target_format_preference_cannot_be_satisfied_by_a_siblings_encoding(): descriptor=files, catalog=CATALOG, ) + + +@pytest.mark.parametrize( + "title", + [ + "The Long Earth Series By Stephen Baxter and Terry Pratchett", + "The Long Earth series, books 1 to 5 - Terry Pratchett & Stephen Baxter", + ], +) +def test_whole_series_names_are_collections(title): + work = {"title": "The Long Earth", "authors": ["Terry Pratchett", "Stephen Baxter"]} + value = release().model_copy( + update={"title": title, "raw_title": title, "authors": work["authors"]} + ) + assert collection_candidate(value, work)