mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-11-15 06:08:26 +00:00
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 -->