View Single Post
Old 07-13-2021, 12:58 PM   #1
degiz
Junior Member
degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.degiz is faster than slow light.
 
Posts: 3
Karma: 29060
Join Date: Jul 2021
Device: Kobo Forma
Script to import highlights from kobo device to Calibre reader

Hey everyone,

tl;dr I've written a script to import highlights from a kobo book to calibre app viewer; please go ahead and try it!

My reading workflow is very much about the highlights, so I like to have them backed up, and easy to come back to in the future. The key point is to be able to see not only the highlight but also the concrete page in the book as if it's a note in a paper book. I use Calibre to manage my ebook library, and would love to keep using it for my highlights collection as well.

I've recently got a Kobo Forma reader (which I love!) and was happy to find out that all highlights are stored in the SQLite database, with some precise location that looks like that:
Code:
span#kobo\.46\.1
I've figured out that this location system is very similar to the EPUB CFI, the one that calibre is using for its ebook viewer highlight, and wrote a python script that imports the highlights from Kobo database, and inserts them into a calibre database as if you annotated text in the Calibre (see the screenshots).

You can find the script here.

So in a nutshell the script does the following:
  • reads all highlights from Kobo DB
  • matches the Kobo-book to the Calibre-book
  • converts location from Kobo-CFI to Epub-CFI
  • inserts highlights to the calibre DB, making sure there're no duplicates

I don't think that amending the original calibre DB is the best approach, but consider that a hacky solution before I find out the proper one

Current limitations:
  • not a calibre plugin, but an external script, so you need some basic XP with terminal
  • works only for (k)epub books (hardcoded format), but tbh I don't have non-epub books at all

I've tested the script on ~10 epub books (in English and Russian), and it works well, I personally use it for each book I read now.

I've only tested this on Mac Os manually, and I'm planning to add some proper tests later when other people also give it a try.

Please make sure to backup your calibre library!

I hope the script will work for you too, and looking forward to hear your opinion!
Attached Thumbnails
Click image for larger version

Name:	screen_kobo.jpg
Views:	533
Size:	183.4 KB
ID:	188168   Click image for larger version

Name:	screen_calibre.png
Views:	536
Size:	267.0 KB
ID:	188169  
degiz is offline   Reply With Quote