Skip to content

BookOrbit: match the Kindle's books right after sign-in and on Wi-Fi - #366

Merged
9retirement6irk merged 43 commits into
mainfrom
fix/bookorbit-match-at-signin
Nov 23, 2026
Merged

9retirement6irk merged 43 commits into
mainfrom
fix/bookorbit-match-at-signin

Conversation

@9retirement6irk

Copy link
Copy Markdown
Owner

Fix for "my downloaded books aren't recognised under BookOrbit" (the owner's Scribe, 2026-11-22). Built on #365 (merge #347 to #365 first, in number order).

What was wrong

After signing in to BookOrbit, Dog Days (downloaded from Grimmory earlier) still said Download in the Catalog. The owner's log shows why: no match-check request was made at all. Matching the Kindle's files to BookOrbit's books ran only when the library list was rebuilt, and nothing rebuilds it at sign-in. #350's description said it happened at sign-in; it didn't.

What changes for the user

Books already on the Kindle are matched to BookOrbit's by their files 2 seconds after signing in to BookOrbit, and again whenever Wi-Fi comes on. Matched books say Read in the Catalog and sync their progress. When nothing is new or changed it asks nothing.

Only the very same file matches. If BookOrbit holds a different copy (another edition, or a file its import rewrote), the book stays unmatched and has to be downloaded from BookOrbit once. I can't tell from here which case Dog Days is: the log line below will.

Tested

Full suite: 0 suites failed. Plugin harness 2874 passed (matched after afterLogin without an explicit call; the Wi-Fi hook calls it; an earlier check now allows match-check as the one POST that only asks).

To try on a device

  1. Sign out of BookOrbit and in again (or just turn Wi-Fi off and on).
  2. Wait ten seconds, then open Dog Days in the Catalog: it should say Read.
  3. Send the diagnostic log. The line BookOrbit: matched N of M books on this Kindle by their files says how many were recognised; if N is 0, the files differ from BookOrbit's and I'll add matching by title and author.

Not labelled beta, as asked for the BookOrbit PRs.


Generated by Claude Code

The stand-in the BookOrbit work is tested against: the KOReader sign-in,
version and capabilities, catalog, covers, downloads, match-check, progress
(plugin and KOSync), and the main API's key, audiobook manifest, audio files
and listening position. Written from BookOrbit's routes and field names at
commit e60ab43; none of its code is copied.

tools/gzreader/bookorbit-probe.py asks a real server the same questions and
prints status codes and field names only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
A second client with the Grimmory client's methods (gzreader_bookorbit.lua),
answering in the shapes the Catalog, the index, covers and downloads already
read. plugin.api stays the same table; its class changes with the sign-in
(store.backend). Sign-in is BookOrbit's KOReader sync user: only the
password's MD5 is kept (with the other secrets, off the USB drive).

Nothing is sent to BookOrbit yet (books_only): progress, highlights,
bookmarks, statistics, shelves and audiobooks come in their own steps.

Each server has its own book ids: the other server's list of downloads is
put aside (the files stay), and covers are kept in separate folders.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Grimmory, BookOrbit, or on its own (books sent from a browser). The page
after it offers what fits the answer: the setup page with that server picked,
typing its sign-in, or the Send books page. The guide's sync page says what
is true for the answer. The answer is kept (store.book_source) as the guide's
default; it switches nothing off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…g, emulator check)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
… guide's first question

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
run.sh's sections are rewritten by #321, so a new suite there kept this out
of the test build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
… of run_tests.lua

Other open PRs add their blocks at the end of the file, which kept this out
of the test build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…icates when Python has none

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…er's does

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
A real server (v3.9.0) lists a book's main file as "primary", not "content":
with only "content" accepted, no book would have downloaded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…rprint

Progress goes out by the file's fingerprint (KOReader's partial MD5) with
KOReader's own percentage and XPointer, and comes back from the book's
catalog record in the shape gzreader_sync.lua already reads. Books in the
folder that aren't tied to a BookOrbit book are matched with match-check.

What the server takes is in the client's `supports` (main's serverCan);
one sentence built from it says what is and isn't synced, wherever shown.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
gzreader_bo_annotations.lua speaks BookOrbit's exchange: the keys of every
highlight in the book, the ones new or changed since the last exchange, and
back what this Kindle lacks (add, edit, delete), acknowledged once applied.
Same interface as the Grimmory module; main picks by book server.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
gzreader_bo_bookmarks.lua speaks BookOrbit's bookmark exchange (keys of the
book's bookmarks, the new ones, and back what to add and remove; a bookmark
BookOrbit gives is dated here and acknowledged with its key). Only when the
server advertises bookmarkSync. Same interface as the Grimmory module.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
List (books/query), details and chapters (the manifest), download with
resume (asset content, Range), and the listening position both ways
(playback-state, with its revisions and a fresh operation id), all in the
shapes gzreader_audiobook.lua reads Grimmory's in. An audiobook's id here is
"a<id>": a BookOrbit book can be an ebook and an audiobook under one id.

The key is checked at entry (auth/me), kept with the other secrets, never
shown back or logged. The probe now also checks whether the e-reader sign-in
alone can download audio.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Reading time: the page rows of KOReader's statistics database since the last
upload, per BookOrbit book (by fingerprint), to /koreader/plugin/page-stats,
read and sent in a background process a moment after a book closes
(gzreader_bo_stats.lua). Ratings: the client's putRating and the record's
rating, through the existing rating sync.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
A book's menu can change your BookOrbit collections through the main API
(GET collections, POST/DELETE collections/:id/books) when the API key is
saved. Only collections that are yours are offered. Without the key the
menu says where to enter it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
The Catalog's BookOrbit card gets Request a book (title, author, book or
audiobook) and My book requests (state, the decision's note, cancel),
through BookOrbit's book-requests routes with the API key. The key's
setting is now "BookOrbit API key", since collections and requests use
it as well as audiobooks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
The setup page can sign in to BookOrbit with its address and an API key.
The key (with the KOReader sync permission) reads the account's sync user
name and, from the server's preconfigured-plugin zip, its sync key; the
Kindle then signs in as usual. With no sync sign-in on the account, one
is made under the account's name with a random password. Nothing in the
zip is kept or run, and neither key is logged or shown back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
… may do

Step 8 groundwork. The probe now sends the browser's preflight and a
signed-in request as the sync page's origin and says whether the server
(its reverse proxy) answers it, and reports what the API key is allowed
to do: the KOReader sync sign-in, collections, book requests. The mock
can stand behind a proxy that lets one origin in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Home's reading stats widget takes its numbers from the server signed in
to: Grimmory's user stats as before, or BookOrbit's catalog dashboard
(streak, goal, minutes per day for a year, badges). A tap opens a page
with charts drawn from those numbers. The mock gets the dashboard route,
and one comment line in its stand-in zip that matched BookOrbit's source
is reworded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Async.ensureToken forked a do-nothing "refresh login" process for every
download and index run with BookOrbit (it has no access token to check).
It now answers at once. Grimmory's bookmarks module is required only when
Grimmory is the server. The stats job is tagged "reading stats". A new
emulator tour compares a book session signed in to nothing and to
BookOrbit and lists the requests made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
Caddy and nginx (and Nginx Proxy Manager) rules for the sync page's
origin, what they do and don't allow, and how to check with the probe.
The page itself doesn't speak BookOrbit yet; the wiki says so.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
…etting

The key's needed access and permissions are named as BookOrbit's Create
API key page names them, in the setup page, the Kindle's help and the
wiki (with a table per feature). Messages use BookOrbit's real settings
paths. With a key that can see the sync sign-in, GZreader reads how
read-aloud EPUBs are delivered and says so when it's the original with
narration. A sign-in GZreader makes keeps BookOrbit's defaults.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
The tab is Books and the heading names the server, following the Book
server choice. BookOrbit gets its own form (API key first, sync name and
password as the other way, no single sign-on); the other server's fields
are hidden and disabled. Connecting, disconnecting and the Kindle's
summary name the right server. Saving or removing the BookOrbit API key
is confirmed on the page with what the key can do.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
matchLibraryFiles only ran from libraryUpkeep (when the library index
was built), so after switching servers the books already downloaded
still said Download. It now runs 2 s after a BookOrbit sign-in and when
Wi-Fi connects (it does nothing when no file is new or changed).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
#338 gives Gzip.inflate a second argument of its own (a size limit), so
changing its signature here kept this PR and everything built on it out
of the test build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqNYrwobY8un97LQ2jriQC
@9retirement6irk 9retirement6irk added the beta Include in the beta branch (test builds over Wi-Fi) label Nov 23, 2026
github-actions Bot added a commit that referenced this pull request Nov 23, 2026
# Conflicts:
#	plugins/gzreader.koplugin/gzreader_changelog.lua
github-actions Bot added a commit that referenced this pull request Nov 23, 2026
# Conflicts:
#	plugins/gzreader.koplugin/gzreader_changelog.lua
@9retirement6irk
9retirement6irk merged commit fc7e3ac into main Nov 23, 2026
2 checks passed
@9retirement6irk
9retirement6irk deleted the fix/bookorbit-match-at-signin branch November 23, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta Include in the beta branch (test builds over Wi-Fi)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants