Skip to content

feat(metadata): prefer Kindle for Amazon metadata#2471

Closed
lyallcooper wants to merge 1 commit intobooklore-app:developfrom
lyallcooper:feat/kindle-metadata-priority
Closed

feat(metadata): prefer Kindle for Amazon metadata#2471
lyallcooper wants to merge 1 commit intobooklore-app:developfrom
lyallcooper:feat/kindle-metadata-priority

Conversation

@lyallcooper
Copy link
Copy Markdown

@lyallcooper lyallcooper commented Jan 25, 2026

📝 Description

This change prioritizes the kindle version of a given book when fetching metadata from Amazon over the current paperback/hardback prioritization. Kindle versions, being the only e-book versions on Amazon, usually have more applicable metadata for a given e-book.

Linked Issue: Fixes #1284

🏷️ Type of Change

  • Bug fix
  • New feature
  • Enhancement to existing feature
  • Refactor (no behavior change)
  • Breaking change (existing functionality affected)
  • Documentation update

🔧 Changes

  • Updates Amazon book ID extractor to prefer the Kindle version, if it exists
  • Updates Amazon review count and rating extraction logic to also work for Kindle ASINs

🧪 Testing (MANDATORY)

Manual testing steps you performed:

  1. Built the docker image ghcr.io/lyallcooper/booklore:develop-bff7319f on my fork
  2. Ran it against my existing booklore installation
  3. Fetched/updated metadata using the Amazon provider for various books
  4. Confirmed that Kindle ASIN was fetched instead of paperback or hardcover ASIN
  5. Confirmed that all relevant metadata were fetched as expected, using the Kindle version metadata

Regression testing:

  • Re-fetched metadata for various books in my library, checking to see that all information was fetched correctly

Edge cases covered:

  • Books that don't have a Kindle version fall back correctly to paperback/hardcover version with correct data

Test output:

Backend test output (./gradlew test)
All 2 654 tests pass, 15 skipped in 1m 38s

  349 files  +  145    349 suites  +145   1m 38s ⏱️ + 1m 12s
2 669 tests +1 076  2 654 ✅ +1 065  15 💤 +11  0 ❌ ±0 
2 726 runs  +1 076  2 711 ✅ +1 065  15 💤 +11  0 ❌ ±0 

Results for commit https://github.com/lyallcooper/booklore/commit/bff7319f0611dc1502abcb9e6bb3d980eca3ab30. ± Comparison against earlier commit https://github.com/lyallcooper/booklore/commit/eb2a7537bd0306a7497fedeab232f4d39227229e.
Frontend test output (ng test)
 RUN  v4.0.18 /home/runner/work/booklore/booklore/booklore-ui

 ✓  booklore  src/app/features/magic-shelf/service/book-rule-evaluator-metadata-presence.spec.ts (85 tests) 192ms
 ✓  booklore  src/app/features/magic-shelf/service/book-rule-evaluator.service.spec.ts (199 tests) 425ms
 ✓  booklore  src/app/features/magic-shelf/service/magic-shelf-utils.spec.ts (46 tests) 35ms
 ✓  booklore  src/app/features/book/service/library-health.service.spec.ts (6 tests) 63ms
 ✓  booklore  src/app/app.component.spec.ts (7 tests) 330ms
 ✓  booklore  src/app/features/magic-shelf/component/magic-shelf-component.spec.ts (73 tests) 899ms
 ✓  booklore  src/app/core/security/auth-initializer.spec.ts (2 tests) 32ms
 ✓  booklore  src/app/app.spec.ts (1 test) 3ms

 Test Files  8 passed (8)
      Tests  419 passed (419)
   Start at  12:37:55
   Duration  6.04s (transform 1.15s, setup 3.02s, import 4.52s, tests 1.98s, environment 5.74s)

📸 Screen Recording / Screenshots (MANDATORY)

Before After
booklore-before.mp4
booklore-after.mp4

✅ Pre-Submission Checklist

All boxes must be checked before requesting review. Incomplete PRs will be closed without review. No exceptions.

  • This PR is linked to an approved issue
  • Code follows project backend and frontend conventions
  • Branch is up to date with develop (merge conflicts resolved)
  • I ran the full stack locally (backend + frontend + database) and verified the change works
  • Automated tests added or updated to cover changes (backend and frontend)
  • All tests pass locally and output is pasted above
  • Screen recording or screenshots are attached above proving the change works
  • PR is a single focused change (one bug fix OR one feature, not multiple unrelated changes)
  • PR is reasonably scoped (PRs over 1000+ changed lines will be closed, split into smaller PRs)
  • No unsolicited refactors, cleanups, or "improvements" are bundled in
  • Flyway migration versioning is correct (if schema was modified)
  • Documentation PR submitted to booklore-docs (if user-facing changes)

🤖 AI-Assisted Contributions

If any part of this PR was generated or assisted by AI tools (Copilot, Claude, ChatGPT, etc.), all items below are mandatory. You are fully responsible for every line you submit. "The AI wrote it" is not an excuse, and AI-generated PRs that clearly haven't been reviewed are the #1 reason PRs get closed.

  • I have read and understand every line of this PR and can explain any part of it during review
  • I personally ran the code and verified it works (not just trusted the AI's output)
  • PR is scoped to a single logical change, not a dump of everything the AI suggested
  • Tests validate actual behavior, not just coverage (AI-generated tests often assert nothing meaningful)
  • No dead code, placeholder comments, TODOs, or unused scaffolding left behind by AI
  • I did not submit refactors, style changes, or "improvements" the AI suggested beyond the scope of the issue

…r Amazon

Prioritize Kindle editions when fetching Amazon metadata:
- Search for Kindle format first, falling back to Paperback then Hardcover
- Kindle ASINs typically provide better ebook-specific metadata

Fix review rating and count extraction for all page formats:
- Use direct selectors (#acrPopover, #acrCustomerReviewText) instead of
  parent containers which differ between Kindle and physical book pages
- Extract rating from title attribute using regex that works across all
  locales (US: "4.6 out of 5", DE: "4,6 von 5", JP: "5つ星のうち4.2")
- Handles both decimal separators (. vs ,) and thousand separators

Add unit tests for rating/count extraction and format prioritization.
@lyallcooper lyallcooper force-pushed the feat/kindle-metadata-priority branch from 6e76a93 to 2009b87 Compare March 3, 2026 12:24
@acx10 acx10 closed this Apr 29, 2026
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.

2 participants