Update kobo.py to include subtitle if field exists in custom columns#3358
Update kobo.py to include subtitle if field exists in custom columns#3358dotknott wants to merge 1 commit into
Conversation
|
In my particular case, I wanted the subtitle field to show the number of pages as, e.g., "256 pages". This solution seems to only like columns with plain text or numbers. I made the #subtitle column be populated with integers from Count Words and it worked, however it only outputed "256", which was only half my desired end goal. I tried making a new #subtitle column, having it referencing the number column and with the template {#pages:} pages. The output of the column was indeed "256 pages", but sync would fail allways. It seems it doesn't like templates. However, I found a solution. Going back to making the #subtitle column be the one populated by Count Pages and changing line 440 to |
…ata (#267) Backport of janeczku/calibre-web PR #3358 (@dotknott). Calibre libraries commonly store per-book subtitles in a custom column (especially non-fiction, academic). The Kobo sync protocol has a Subtitle key in the metadata block that the device renders below the title, but stock CW + this fork never populated it — the subtitle existed in Calibre and never made it to the device. `get_subtitle(book)` looks up a Calibre custom column labeled `subtitle`, reads the value off `book.custom_column_N`, and returns the string (or empty when no column or no value). `get_metadata` includes `"Subtitle": get_subtitle(book)` so every sync entry carries the key. The upstream patch had three null-handling bugs (`.all()[0]` IndexError on missing column, unreachable else branch, TypeError on None attribute). Rewritten with explicit empty-result handling at every fork. 8 RED→GREEN tests in `tests/unit/test_kobo_subtitle_custom_column.py` cover all 6 branches plus metadata-dict integration. 202 adjacent kobo tests green. Credit: @dotknott in janeczku/calibre-web#3358.
|
Backported into Calibre-Web-NextGen Heads-up for stock-CW users: this build is CWA-derived, so it adds auto-ingest + kepubify + KOReader sync on top of plain calibre-web. Thanks @dotknott for the original PR. |
Since Subtitle is becoming more common in Calibre DB setups with Kobo users, I added subtitle to the sync data when there's a custom column labeled 'subtitle'. When no matching column exists it returns an empty string.