Repository navigation
feat(library): write series, genres and tags into epub files - #58
Merged
Merged
Conversation
KOReader only sees what's in the file, so plugins built on its book info (Bookshelf) couldn't group books by Shelfloom's series or show its genres. Each EPUB's OPF now gets: - calibre:series and calibre:series_index for the main series (one the book has a number in, then the most specific), which KOReader reads first, plus EPUB 3 belongs-to-collection entries for every series; - a <dc:subject> per genre and tag, which KOReader reads as keywords (Bookshelf's genres). Existing series and subject entries are replaced; nothing else in the file changes. A sync runs a few seconds after edits through the API and at the end of every library scan. A fingerprint per book means a file is only rewritten when its metadata changed, and a book Shelfloom knows nothing about is left as it came. Rewritten files get their hashes refreshed, keeping the old ones so KOReader still matches. Also fixes rewriting EPUBs whose directory entries are stored deflated (zip.Writer.Copy refuses them): cover embedding failed on those too.
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
KOReader's Bookshelf plugin groups books by what KOReader extracts from the file itself (through CoverBrowser), so it never saw Shelfloom's series, series numbers, genres or tags.
What
Shelfloom now writes into each EPUB's OPF:
calibre:series,calibre:series_index#Nbadgebelongs-to-collection+collection-type/group-position<dc:subject>eachepub_metadatatable) means a file is only rewritten when its metadata changes; books Shelfloom has nothing for are left alone.book_hashesso KOReader still matches them.zip.Writer.Copyrefuses them). Cover embedding was failing on these too.Testing
calibre:seriesmatches the DB for all of them, and a full rescan finds every file unchanged.After deploy
The first sync rewrites about 650 EPUBs once. KOReader caches book info and doesn't notice that a file changed. To pick up the new metadata on the device, refresh the cached book information in the file browser (CoverBrowser).