Skip to content

feat(scanner): match library files by series name and position#390

Merged
vavallee merged 2 commits intomainfrom
feat/scanner-series-match
Apr 24, 2026
Merged

feat(scanner): match library files by series name and position#390
vavallee merged 2 commits intomainfrom
feat/scanner-series-match

Conversation

@vavallee
Copy link
Copy Markdown
Owner

Summary

  • Adds Series and SeriesNumber fields to ParsedFile
  • ParseFilename now extracts series info from bracket notation ([Series Name #N], [Series Name, Book 1]) and paren notation ((Series Name #N), (Series Name, Book 1)) — series name must start with a letter to avoid false-positives on ISBNs and years
  • Falls back to parent directory name for ABS-style layouts where the folder carries the series+number (Author/Series Name, Book 1/title.m4b)
  • ScanLibrary falls back to series+position matching when ASIN and title+author both fail — exact series-title match + position, returns no match when ambiguous (two series with the same name both have a book at that position)
  • Adds WithSeriesRepo builder to Scanner
  • New GetBookBySeriesPosition repo method in SeriesRepo

Fixes library scan failures for users migrating from LazyLibrarian

Users whose existing libraries have series-based filenames like:

[Dune Chronicles #1] Dune - Frank Herbert.m4b
[Stormlight Archive, Book 1] The Way of Kings - Brandon Sanderson.epub
(Dune Chronicles, Book 1) Dune - Frank Herbert.m4b

These previously returned unmatched on library scan. With this PR they reconcile correctly against wanted books via series name + position.

Notes

  • ABS layout Author/Series Name/01 - Title.m4b (no number in folder name) still relies on tag reading or title match — the parser can't infer series number from a plain folder name without a position
  • ABS layout Author/Series Name, Book 1/Title.m4b (number in folder name via paren) is fully supported

Test plan

  • go test ./internal/importer/... ./internal/db/...

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 12.82051% with 68 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/db/series.go 0.00% 41 Missing ⚠️
internal/importer/scanner.go 0.00% 16 Missing and 1 partial ⚠️
internal/importer/parser.go 50.00% 7 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@vavallee vavallee force-pushed the feat/scanner-series-match branch from bfed9e1 to c803381 Compare April 24, 2026 20:22
Closes: user feature request (LazyLibrarian migration, ABS layout)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vavallee vavallee force-pushed the feat/scanner-series-match branch from c803381 to 1809bca Compare April 24, 2026 20:46
@vavallee vavallee merged commit ec2770f into main Apr 24, 2026
25 of 26 checks passed
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