calibre import plugin: stamps EPUBs with a stable document id and per-mille position markers for the Coven Reader / koinsight stack
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jonathan Gluck f374290637 Stop tracking __pycache__
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 18:32:18 -04:00
.gitignore Stop tracking __pycache__ 2026-10-07 18:32:18 -04:00
__init__.py docid continuity: record coven:<docid> on the book, re-stamp later files with it 2026-09-16 14:40:06 -04:00
plugin-import-name-coven_stamper.txt Coven Stamper: stable doc id + per-mille position markers on EPUB import 2026-09-15 12:13:34 -04:00
README.md Coven Stamper: stable doc id + per-mille position markers on EPUB import 2026-09-15 12:13:34 -04:00
stamp.py stamp: coven:chapters -- which spine item holds which markers 2026-09-30 23:08:47 -04:00

Coven Stamper (calibre plugin)

Stamps every EPUB imported into the library with a stable document id (<meta name="coven:docid">) and per-mille position markers (data-cp="NNN" on the element whose text crosses each 0.1% of the book's visible characters). See __init__.py for why.

Install / update:

cd ~/docker/cwa/plugins/coven_stamper && zip -j ../coven_stamper.zip __init__.py stamp.py plugin-import-name-coven_stamper.txt
cp ../coven_stamper.zip ~/docker/cwa/config/.config/calibre/plugins/
docker compose -f ~/docker/cwa/docker-compose.yml restart   # CWA auto-registers zips at start (CWA_CALIBRE_USER_PLUGINS=1)

Check: docker exec cwa calibre-customize -l | grep -i coven.

Run by hand (no calibre needed beyond lxml): docker exec -i cwa calibre-debug -e /tmp/stamp.py in.epub out.epub

Existing library books are not re-stamped — the hook fires on import only. A one-off pass over /calibre-library is a separate step (and the fork keeps checksums: see scripts/generate_book_checksums.py before rewriting files in place).

Legacy ids: a book already known to koinsight under some other id (e.g. Player Manager 10 is ea18d92c… there, from the Kobo) gets the library file's own partial-MD5 as its stamped id. To keep the old one, stamp that file once by hand with the existing id in the OPF, or rename the id server-side. The stamper never overwrites an existing coven:docid.