[books] Match books by Google Books ID or author name

This commit is contained in:
2026-09-01 11:54:14 -04:00
parent d569d31715
commit c400f8a18d
6 changed files with 255 additions and 34 deletions

View File

@ -589,16 +589,32 @@ The Edit log form should have from top to bottom:
Currently the images on the book source page go nowhere. We should add links to Amazon and Goodreads, and maybe Bookshop.org if we can find a way to generate that link easily.
** TODO [#B] Make book matching use Google Books ID or author name :bug:books:matching:
** DONE [#B] Make book matching use Google Books ID or author name :bug:books:matching:
*** Description
This may be a no-op situation as we've moved away from Google Books. But maybe we haven't.
Turns out we hadn't. Google Books is still a primary metadata source alongside
OpenLibrary and ComicVine. =Book.find_or_create()= only matched by
=original_title=, which is fragile. It now also matches by Google Books ID or
author name (like Track does with =musicbrainz_id=).
*** Implementation
- File: ~vrobbler/apps/books/models.py~ (line 270)
- =Book.find_or_create()= only matches by =original_title=, which is fragile.
Should also match by Google Books ID or author name (like Track does).
- ~vrobbler/apps/books/sources/google.py~: =lookup_book_from_google()= now
accepts an optional =author= (used as an =inauthor:= query term) and returns
the top-level Google Books volume =id= as =google_books_id=.
- ~vrobbler/apps/books/models.py~: added a =google_books_id= CharField to
=Book=. =find_or_create()= now:
- short-circuits on an exact =original_title= match (no lookups);
- after enrichment, reuses an existing book by =google_books_id=, falling
back to a =title= + author match — mirroring how Track keys off
=musicbrainz_id=.
- =fix_metadata()= gained a Google Books fallback so asynchronously enriched
(e.g. KoReader-imported) books also capture =google_books_id=.
- ~vrobbler/apps/books/management/commands/cleanup_book_metadata.py~: passes
the author to the Google lookup and persists =google_books_id= on backfill.
- Migration ~0040_book_google_books_id~ adds the field.
** DONE [#B] Books created via koreader do not get enriched :books:metadata:bug:
:PROPERTIES: