Repository navigation
Conversation
BookOrbit describes the media overlay of every EPUB it has inspected,
including `{ available: false, durationSeconds: null }` for a file
without narration. The connector treated any `mediaOverlay` value as a
read-along EPUB, so a book with both a plain EPUB and a read-along EPUB
looked like it had two read-along files, and the connector fell back
to the primary file, which is usually the read-along one.
That file carries the narration audio and is often larger than the
200 MiB EPUB download limit, so XPath <-> CFI conversion failed. Pulls
arrived as a bare percentage (`bookorbit:<pct>`) and pushes went out
without a CFI. A device reading the plain EPUB then placed itself by
percentage and never settled on the same position as BookOrbit.
Count an EPUB as read-along only when its overlay is available. The
test fixtures now use the object shape BookOrbit returns instead of
`mediaOverlay: true`, and a new test covers a plain EPUB reported with
an unavailable overlay next to a read-along primary.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
The BookOrbit connector treats any EPUB that has a
mediaOverlayfield as a read-along EPUB. BookOrbit also reports that field for EPUBs without narration, as{ available: false, durationSeconds: null }. When a book has both a plain EPUB and a read-along EPUB, the connector therefore sees two read-along files and falls back to the primary one, which is usually the read-along EPUB.This PR counts an EPUB as read-along only when
mediaOverlay.available === true(or when the filename ends in.readaloud.epub, as before).Problem
fileId()insrc/connectors/bookorbit.tspicks the EPUB the connector syncs against. It skips read-along files, which can be very large because they carry the narration audio:GET /api/v1/books/:idin BookOrbit returnsmediaOverlayas an object for every EPUB it has inspected (mediaOverlayCapabilityFromFieldsin BookOrbit'sserver/src/modules/reader/epub/epub-media-overlay-capability.ts). For example, thefilesof a book with a plain EPUB and a read-along EPUB look like this (trimmed):[ { "id": 81, "format": "epub", "role": "content", "mediaOverlay": { "available": false, "durationSeconds": null } }, { "id": 80, "format": "epub", "role": "primary", "mediaOverlay": { "available": true, "durationSeconds": 36000 } } ]!!{ available: false }istrue, so the plain EPUB is classified as read-along. With no plain file left, the pool is every EPUB and the primary one (the read-along file) is chosen.Effect
Observed with BookOrbit 3.11 and a book that has a plain EPUB (< 1 MB) and a read-along EPUB (813 MB, primary). The device (a CrossPoint reader) holds the plain EPUB, which is what BookOrbit's OPDS feed serves when a plain EPUB exists.
externalEdition.bookorbit:836572) instead of an XPointer. The device places itself by percentage, which it computes differently from BookOrbit, and lands at a chapter start (80% on the device vs. 84% in BookOrbit).The bug came in with the read-along EPUB choice in #144. The existing tests modeled the field as
mediaOverlay: true, which does not match the shape BookOrbit returns, so they could not catch it.Fix
Tests
{ available: true }) and a plain EPUB ({ available: false }) resolves to the plain EPUB. It fails onmain(expected '80' to be '81') and passes with the fix.mediaOverlay: true.npm test: 88 files, 1279 tests pass.tsc --noEmitis clean.Notes
Existing matches keep the file they were resolved to when they were created. A match that already stores a read-along file keeps using it until the book is matched again (or until that file returns 404, which already triggers a lookup). Re-resolving read-along editions that were stored before this fix could be a follow-up.