Calibre library batch export for Xteink X4/X3 (CrossPoint firmware)
Find a file
phil c9252ea184 Initial release: Calibre library batch export for Xteink X4/X3
Runs the CrossPoint Reader plugin's optimization pipeline over every
EPUB in a Calibre library and writes SD-card-ready output named from
metadata.db as Author/Title (Year)/Author - Title (Year).epub.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 12:46:25 +02:00
export_library_to_x4.py Initial release: Calibre library batch export for Xteink X4/X3 2026-07-12 12:46:25 +02:00
LICENSE Initial release: Calibre library batch export for Xteink X4/X3 2026-07-12 12:46:25 +02:00
README.md Initial release: Calibre library batch export for Xteink X4/X3 2026-07-12 12:46:25 +02:00

calibre-x4-export

Batch-exports a Calibre library for the Xteink X4/X3 e-ink readers running the CrossPoint firmware — ready to copy straight onto the device's SD card.

The Xteink readers have ~380 KB of usable RAM. Unprocessed EPUBs routinely crash them with out-of-memory errors: the firmware lays out one paragraph at a time holding every word in RAM, so a single multi-KB <p> (page-long literary paragraphs, à la Fosse or Bernhard) kills the reader even inside a small file. Large chapter files, embedded fonts, oversized/color images and multi-KB base64 data-URIs cause the same failure mode.

This script runs the full optimization pipeline of the CrossPoint Reader Calibre plugin (images → grayscale/screen-size JPEG; paragraphs and chapters split to device-safe sizes; fonts stripped; data-URI images extracted) over every EPUB in the library and writes the results as:

<outdir>/Author/Title (Year)/Author - Title (Year).epub

Metadata (author, full title, publication year) comes from Calibre's metadata.db, so output names carry no library IDs or truncated titles. Names are transliterated to ASCII (ä→ae, ø→o, …) for maximum FAT/firmware compatibility. "Lastname, Firstname" author entries are flipped to "Firstname Lastname".

Requirements

  • Python 3.8+ with Pillow (python-pillow)
  • Calibre with the CrossPoint Reader plugin installed (≥ 0.3.0 with the text-splitting optimizer) — the pipeline is loaded from the installed plugin zip, so this script always matches your plugin version
  • A Calibre library (default path: ~/sync/Calibre, see constants at the top)

Usage

# convert into ~/x4-export
python3 export_library_to_x4.py

# or convert straight onto the mounted SD card
python3 export_library_to_x4.py /run/media/$USER/SDCARD/Books

Re-runs are incremental: books whose output already exists and is newer than the library file are skipped, so adding a book to Calibre and re-running only converts the new book.

Every text transformation in the pipeline verifies that the visible text is unchanged and reverts itself on any mismatch — a conversion never silently corrupts a book. Failures (e.g. corrupt EPUBs) are reported in the summary and never abort the batch.

Caveats

  • Only EPUBs are exported; PDFs and other formats are skipped.
  • If a book was already opened on the device under the same path, clear the firmware's section cache afterwards (Settings → Clear Cache, or delete /.crosspoint/epub_* on the SD card): the cache is keyed by file path only and is never invalidated by content changes.

License

MIT