Skip to content

feat(metadata): use a GoogleBooks archive identifier for the Google Books lookup - #587

Open
mbret wants to merge 3 commits into
developfrom
claude/api-google-volume-id-from-archive
Open

feat(metadata): use a GoogleBooks archive identifier for the Google Books lookup#587
mbret wants to merge 3 commits into
developfrom
claude/api-google-volume-id-from-archive

Conversation

@mbret

@mbret mbret commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Follow-up to #586, which added the UI and archive-writing side. That PR lets you store a Google Books volume id in a book; this one makes oboku act on it.

Independent of #586 — no overlapping files, and an EPUB tagged by another tool can already carry a GoogleBooks identifier today. Mergeable in either order.

What

resolveArchive already reports a GoogleBooks identifier from the OPF; the metadata pipeline just never looked at it.

  • FileMetadata advertises googleVolumeId
  • getMetadataFromArchive reads it off the resolved identifiers
  • the Google Books lookup falls back to it after the [oboku~google-volume-id~…] filename directive, mirroring the existing ISBN chain (no user-editable volume id exists to sit in front of the directive)
  • the book details metadata pane shows it on the file source

Volume id now wins over ISBN — for this API only

A volume id addresses one Google Books record. An ISBN can match several printings of the same work, so which record it lands on is effectively a coin toss between editions. Where both are known, the volume id is the better key, so getGoogleBookMetadata now tries it first.

Scoped deliberately: this is the lookup order inside the Google Books provider. ISBN remains the priority identifier in the source chain that decides which metadata ultimately wins for a book.

Comics work too

identifierValue(metadata.identifiers, "GoogleBooks") comes straight from archive-reader 1.357.0 and reads the id out of a catalog link as well as an explicitly typed identifier — so a comic, whose only reference field is ComicInfo's Web, is picked up too. That was the one gap when this PR was first opened, and it closed without needing #586's helper: the crosswalk moved upstream in prose-reader#326 and the hand-rolled scheme check here is gone.

Verification

  • 3 new tests on getMetadataFromArchive (identifier present, absent, and not confused by an ISBN or a catalog URL)
  • apps/web 297 tests, packages/shared 113 tests pass
  • tsc clean in apps/api, apps/web, packages/shared; biome clean

One gap worth knowing: the lookup-order change itself is not covered by a test. getGoogleBookMetadata imports src/lib/google/googleBooksApi through apps/api's baseUrl, which the repo's vitest setup can't resolve (there is no vitest config, and jest only picks up *.spec.ts), so the module can't be imported from a test at all today. Adding that alias config would make this and the rest of apps/api/src/lib testable — happy to do it as its own PR.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oboku Ready Ready Preview Aug 26, 2026 1:09pm
oboku-landing Ready Ready Preview Aug 26, 2026 1:09pm

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f41f975b7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +335 to +336
freshFileMetadata?.googleVolumeId ??
reusedFileMetadata?.googleVolumeId

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Invalidate cached file metadata for the new identifier

For an existing book whose type: "file" metadata was extracted before this field existed, an unchanged provider timestamp and size cause the download to be skipped and reusedFileMetadata cannot contain googleVolumeId. Consequently, every ordinary scheduled or manual non-force refresh continues using the ISBN/title lookup and never discovers the embedded GoogleBooks identifier; only changing the file or selecting a hard refresh repairs it. Version the extraction cache or arrange a one-time re-extraction for cached entries that predate this field.

Useful? React with 👍 / 👎.

Comment thread apps/api/src/features/metadata/retrieveMetadataAndSaveCover.ts
Comment thread packages/shared/src/metadata/index.ts
mbret and others added 3 commits August 26, 2026 15:05
…ooks lookup

An archive that carries a `GoogleBooks` identifier already resolves it — the
lookup just never looked. `FileMetadata` now advertises `googleVolumeId`, the
archive extractor reads it, and the single Google Books lookup falls back to
it after the filename directive, mirroring the existing ISBN chain (there is
no user-editable volume id to sit in front).

A volume id names one edition, so this is a more precise lookup key than a
title and than an ISBN shared across printings. The existing preference
order inside getGoogleBookMetadata is unchanged: an ISBN still wins over a
volume id when a book has both.

Only the bare `GoogleBooks` scheme is recognised. A catalog URL such as
`books.google.com/books?id=…` — which is how ComicInfo `<Web>` would carry
the same reference — is left for the crosswalk that needs
@prose-reader/metadata-fetcher.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A volume id addresses one Google Books record; an ISBN can match several
printings of the same work, so the record it lands on is a coin toss between
editions. Where both are known, the volume id is the better key for this API.

Only the Google Books lookup order changes. ISBN remains the priority
identifier in the source chain that decides which metadata wins.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The file variant advertises it now, so the example contradicted the type it
was documenting. No field is variant-less any more, so the merged view is
described without one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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