feat: look up a book by its provider ID or link #100

Merged
jfro merged 5 commits from feat/provider-id-lookup into main 2026-10-26 00:27:49 +00:00
Owner

Adds a Provider ID tab to Add Book: paste a book's link or ID from Hardcover, Open Library or Google Books and get that exact book or edition back, shown with its cover and provider, ready to add.

Accepted:

  • Open Library: OL…W (work) or OL…M (edition), or an openlibrary.org/works/… / /books/… link. Merged works (old IDs that now redirect) are followed.
  • Hardcover: hardcover.app/books/<slug> (its most-read edition), …/editions/<id>, or a numeric book ID (312460 or hardcover:312460).
  • Google Books: a volume ID (zyTCAlFPjgYC, google:…), books.google.com/books?id=… or google.com/books/edition/_/<id>.

How:

  • FuzzyCatalog.Catalog.ProviderId.parse/1 works out provider, kind and ID. Anything that isn't well-formed is refused before any request, so nothing user-typed reaches a GraphQL query or URL path unchecked.
  • Providers get an optional lookup_by_id/2 callback (Hardcover, Open Library, Google Books).
  • BookLookup.lookup_by_provider_id/1 logs ID lookup: <provider> <kind> <id> -> <outcome> in <ms>ms; results carry :provider.
  • Hardcover requests now merge :hardcover_req_options (for Req.Test stubs, like the other providers).

Tests: parser cases (incl. injection-shaped input), stubbed Req for each provider and kind (redirects, 404s, Hardcover not configured), controller test for the tab, result and error. mix precommit: 694 tests pass.
Checked live: Open Library work (merged OL893415W → Dune) and edition (OL7353617M → Fantastic Mr. Fox, Roald Dahl). Google returned 429 (shared anonymous quota) and there's no Hardcover token here, so those are covered by stubs only; the Hardcover query fields (book_id, users_count, book slug) match Hardcover's schema docs.

Stacked on #95 (feat/manual-lookup-providers); retarget to main once it merges.

Closes #97

Adds a **Provider ID** tab to Add Book: paste a book's link or ID from Hardcover, Open Library or Google Books and get that exact book or edition back, shown with its cover and provider, ready to add. Accepted: - **Open Library**: `OL…W` (work) or `OL…M` (edition), or an `openlibrary.org/works/…` / `/books/…` link. Merged works (old IDs that now redirect) are followed. - **Hardcover**: `hardcover.app/books/<slug>` (its most-read edition), `…/editions/<id>`, or a numeric book ID (`312460` or `hardcover:312460`). - **Google Books**: a volume ID (`zyTCAlFPjgYC`, `google:…`), `books.google.com/books?id=…` or `google.com/books/edition/_/<id>`. How: - `FuzzyCatalog.Catalog.ProviderId.parse/1` works out provider, kind and ID. Anything that isn't well-formed is refused before any request, so nothing user-typed reaches a GraphQL query or URL path unchecked. - Providers get an optional `lookup_by_id/2` callback (Hardcover, Open Library, Google Books). - `BookLookup.lookup_by_provider_id/1` logs `ID lookup: <provider> <kind> <id> -> <outcome> in <ms>ms`; results carry `:provider`. - Hardcover requests now merge `:hardcover_req_options` (for Req.Test stubs, like the other providers). Tests: parser cases (incl. injection-shaped input), stubbed Req for each provider and kind (redirects, 404s, Hardcover not configured), controller test for the tab, result and error. `mix precommit`: 694 tests pass. Checked live: Open Library work (merged OL893415W → Dune) and edition (OL7353617M → Fantastic Mr. Fox, Roald Dahl). Google returned 429 (shared anonymous quota) and there's no Hardcover token here, so those are covered by stubs only; the Hardcover query fields (`book_id`, `users_count`, book `slug`) match Hardcover's schema docs. Stacked on #95 (feat/manual-lookup-providers); retarget to main once it merges. Closes #97
jfro added this to the v0.9.0 milestone 2026-10-25 22:49:07 +00:00
feat: look up a book by its provider ID or link
All checks were successful
CI / test (pull_request) Successful in 48s
de6a32b7ee
Adds a Provider ID tab to Add Book. Paste a Hardcover book/edition link or
book ID, an Open Library work (OL…W) or edition (OL…M) ID or link, or a
Google Books volume ID or link, and get that exact book back, with its
cover and provider, ready to add.

- ProviderId parses IDs and links; anything that isn't a well-formed ID is
  refused before a request is made (keeps GraphQL and paths clean)
- providers gain an optional lookup_by_id/2: Hardcover queries editions by
  id, book_id (most-read edition) or book slug; Open Library searches by
  work key (following merged-work redirects) or reads the edition record,
  filling authors from their records when the edition has no ISBN; Google
  Books fetches volumes/{id}
- BookLookup.lookup_by_provider_id/1 logs provider, kind, id, outcome and
  duration
- Hardcover requests take :hardcover_req_options so they can be stubbed

Closes #97
jfro changed target branch from feat/manual-lookup-providers to main 2026-10-25 23:01:48 +00:00
Merge origin/main into feat/provider-id-lookup
All checks were successful
CI / test (pull_request) Successful in 1m1s
7514d82d91
# Conflicts:
#	test/fuzzy_catalog_web/controllers/book_controller_test.exs
Merge remote-tracking branch 'origin/main' into feat/provider-id-lookup
All checks were successful
CI / test (pull_request) Successful in 48s
4bc59079ee
# Conflicts:
#	lib/fuzzy_catalog/catalog/book_lookup.ex
jfro merged commit 9fc824cdd1 into main 2026-10-26 00:27:49 +00:00
jfro deleted branch feat/provider-id-lookup 2026-10-26 00:27:50 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/fuzzy_catalog!100
No description provided.