Skip to content

Feat/mam title fallback - #37

Merged
Mancolt merged 3 commits into
mainfrom
feat/mam-title-fallback
Oct 7, 2026
Merged

Mancolt merged 3 commits into
mainfrom
feat/mam-title-fallback

Conversation

@Mancolt

@Mancolt Mancolt commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

When MAM's filename search finds the release's torrent but MAM hasn't marked it snatched yet, booktree accepts it, provided it's the only candidate and its file type, author and title all match strictly. It makes no extra MAM requests and is controlled by Config/mam/accept_unsnatched, which ships as 0.

Mancolt and others added 3 commits October 7, 2026 01:12
… snatched torrent

Config/mam/title_fallback (default off). Every recent MAM-pass miss (Before She
Knew Him and others) had both file-name searches return the release's own
torrent, not yet marked my_snatched: the hook runs booktree minutes after the
download and MAM sets the flag later. With the flag on, such a release gets one
more MAM search in the title and author fields (main title, lower case, plus
author names). Candidates need not be snatched, so each must have the release's
file type, one of its authors and the same title (same numbers and subtitle, no
bundle), and exactly one candidate must pass. The search shares the throttle,
budget, session and cache of the file-name searches, whose text and cache keys
are unchanged; it is skipped after a failed MAM request in the run and with
verbose off (the ranking does not run then). JSON log: mam_attempt "title",
query search "title-author".

Replay harness: Config/mam is merged rather than replaced, and the offline MAM
session has a real cookie jar (cookies=None made an uncached MAM search raise
outside searchMAM's error handling and skip the book's Audible step).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Ut2SJwyL9F8zUJHeM2GLP
Replaces mam/title_fallback (an extra title/author MAM search) with
mam/accept_unsnatched (default off), which makes no extra MAM request: the
file-name searches booktree already sends returned the release's own torrent,
only not yet marked my_snatched, because the hook runs booktree minutes after
the download and MAM sets the flag later.

With the flag on, when neither file-name search returns a snatched row,
getMAMBook also hands back the other rows and MAMBook.pickUnsnatched accepts
the one row (by MAM id, across both searches) that has the release's file
type, one of its authors and the same title (sameMamTitle: same numbers,
subtitle and production; no sibling volume, part or box set). Two or more are
ambiguous and none is used; a snatched row is preferred as before. stdout gets
one line ("No snatched MAM match; using the only unsnatched one ..."), the
JSON log mam_attempt "unsnatched" (match.attempt "mam-unsnatched").

Removed with the title search: searchMAMByTitle, the srchIn split of
searchMAM (back to upstream's body, unchanged text and cache key), the
per-run MAM-failure latch and the query helpers. Kept: _rowToBook, the title
check, the replay harness fixes (Config/mam merged, offline cookie jar).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Ut2SJwyL9F8zUJHeM2GLP
- samePosition: a "Book N" written in one title must agree with the other
  title or with the other side's series parts (MAM series_info for the row,
  the release's own series tags), else the row is refused ("Mother of
  Learning, Book 2" is not a row MAM lists as part 3, nor one without a part).
- Pool key: rows without a MAM id each count on their own (a null id became
  "None" and merged them, hiding an ambiguity).
- Pooled rows have control characters replaced before anything prints or
  files them, and the silent title checks run before isThisMyAuthorsBook
  (which prints the row title), so a row nobody chose cannot add lines to
  stdout. Title/series inputs to the title regexes are clipped.
- CONFIG.md: the verbose/ebooks condition and the position check.
- Tests: position vs series part, id-less rows, control characters, a
  snatched widened hit beating the pool, ebooks without verbose, JSON log.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Ut2SJwyL9F8zUJHeM2GLP
@Mancolt
Mancolt merged commit 96efa54 into main Oct 7, 2026
2 checks passed
@Mancolt
Mancolt deleted the feat/mam-title-fallback branch October 7, 2026 12:38
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