fix(auto-download): match Usenet ebooks by the format in their name (#1704)

Automatic downloads reject Usenet ebook releases whose format is written
as `(epub)` or `[EPUB]` rather than `.epub`. A Hardcover ebook request
whose match is something like `Rick Rubin - The Creative Act (retail)
(epub)`, from Newznab or from a Prowlarr indexer other than
MyAnonamouse, stays pending with `no strict match`.

For an ebook request, `_format_match` wants a detected format, content
type `ebook`, or a supported format after a dot in the title, and these
releases have none of the three. `_prowlarr_result_to_release` only
detects a format for MyAnonamouse, `_newznab_result_to_release` never
sets one, `_detect_content_type_from_categories` maps every 7000–7999
category to `book`, and the names put the format in brackets. The rule
came in with ebook auto-download in #1533.

The title check now looks for a supported format among the title's
words, using the `_tokens` helper that title and author matching already
use. `Dune.epub`, `(epub)`, `[EPUB]`, `{MOBI}` and `- azw3` all count,
and a word that only contains a format, like "Mobile" or "Republished",
doesn't. It replaces the `.<format>` check, which it covers. The
audiobook check is unchanged, and `docs/hardcover-sync.md` now describes
the rule as it works.

I didn't make content type `book` count instead. Magazines, comics and
results with no category get it too, so it would drop the format
requirement for nearly every Newznab and Prowlarr release. One side
effect: with the default formats, a bracketed `(cbr)` or `(cbz)` now
counts where before only `.cbr` and `.cbz` did.

New tests in `TestContentTypeAwareMatching` use a release shaped like
the Usenet ones (no format, content type `book`, NZB). The Creative Act
title matches, the bracketed and dashed forms count, `(m4b)`, `(epub)
(Unabridged)` and a title with no format still fail, and Mobile,
Republished and epubs don't count. The five positive cases fail on main.
`make python-checks` and the auto-download tests pass, and the full
suite has no new failures against main.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Ebook releases can now match supported formats such as EPUB, AZW3, and
MOBI when the format appears as a whole word in the release title,
including in parentheses or brackets.
* Titles containing a format name only as part of a longer word, such as
“Mobile,” won’t be mistaken for that format.
* **Documentation**
* Clarified how format matching works for sources that don’t report an
ebook format.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
codyw912 authored and GitHub committed 2026-11-13 00:47:13 -05:00
1 parent 44e1c6a660
commit 2fbe1dedc2
3 files changed
+68 -3

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ A release is a strict match only when all of the following hold:
- the release title doesn't name a different book that contains the requested one. A "Dune" request won't take *Dune Messiah* or *Children of Dune*, and a bare number after the title (*Mistborn 2*, *Mistborn Two*, *Dune Chronicles Book II*) names a sequel. A title with a number of its own (*Ready Player One*) takes no other number after it, 1 included. Only the parts of the release name that hold the title are judged, so narrators, uploader tags and the book's own series, author and subtitle words don't count against it; a part that is just the series name (*Alex Cross 25*) does not vouch for a one-word title, so a "Cross" request won't take *Alex Cross: Cross Justice*. Two slash-separated names that both hold the title (*Dune / Dune Messiah*) are two books;
- the release is not a derivative of the work: *summary*, *analysis*, *study guide*, *workbook*, *abridged*, *dramatized*, *adaptation* or *graphic novel* anywhere in the name disqualifies it, unless the requested title itself carries the word. *Unabridged* is a full recording and is fine;
- the release is not a multi-book pack: ranges like `1-24` or `Books 1 to 17`, or words like *complete*, *collection*, *box set*, *omnibus*, *trilogy*, *megapack*, *+ short stories*, unless the requested title itself carries them. "Complete and Unabridged" describes one recording and doesn't count. The library check uses the same word list;
- the format fits the request — an audiobook request needs an audiobook signal (`m4b`/`mp3`, a release from an audiobook-only source, or "audiobook"/"unabridged" in the title) and is never an ebook-only file; an ebook request needs one of your **Supported Book Formats** (or an `.epub`-style marker in the title) and no audiobook signal;
- the format fits the request — an audiobook request needs an audiobook signal (`m4b`/`mp3`, a release from an audiobook-only source, or "audiobook"/"unabridged" in the title) and is never an ebook-only file; an ebook request needs one of your **Supported Book Formats**, either reported by the source or named as a whole word in the release title (`Dune.epub`, `(epub)`, `[EPUB]`; *Mobile* is not `mobi`), and no audiobook signal. Usenet and most Prowlarr indexers report no format, so for them the title is what counts;
- for torrents that report a seeder count, it meets **Minimum seeders** — sources that report none (AudiobookBay) are not judged on seeders.
AudiobookBay requires every word of a query, and its posts for one volume of a multi-part book often spell the part differently from the request ("Part Two" for "Part II"), so a query carrying the part finds only the packs that list it. When no row a query returns carries the requested title, the source tries the next query, ending with the title minus its trailing *, Part N* or *Volume N*. The strict match above still decides which part was found.