/kobuddy

Kobo database backup and parser: extracts notes, highlights, reading progress and more

Primary LanguagePythonMIT LicenseMIT

Kobuddy is a tool to backup Kobo Reader sqlite database and extract useful things from it.

It gives you access to books, annotations, progress events and more!

Tested on Kobo Aura One, however database format should be mostly the same on other Kobo devices. I’ll happily accept PRs if you find any issues or want to help with reverse engineering more events.

Installing

From pypi: pip3 install --user kobuddy

You can also use without installing by running ./kobuddy.

Usage

kobuddy --help
usage: kobuddy [-h] [--db DB] [--errors {throw,return}] {books,progress,annotations,backup} ...

Library to parse and provide Python interface for your Kobo reader

positional arguments:
  {books,progress,annotations,backup}
    books               print all books
    progress            print all book reading progress
    annotations         print all annotations (bookmarks/highlights/comments)
    backup              backup the database from your Kobo device

optional arguments:
  -h, --help            show this help message and exit
  --db DB
                        By default will try to read the database from your Kobo device.
                        If you pass a directory, will try to use all Kobo databases it can find.

  --errors {throw,return}
                        throw: raise on errors immediately; return: handle defensively long as possible and reasonable

as a standalone app

Example of printing reading progress:

Perihelion Summer by Greg Egan
Started : 27 Jul 2019 14:39
Finished: 05 Oct 2019 14:00
-- 27 Jul 2019 14:39: reading
-- 04 Aug 2019 16:40: highlight
-- 27 Aug 2019 12:33: reading: 25%
-- 02 Oct 2019 17:33: reading: 39%, read for 7 mins
-- 02 Oct 2019 17:42: reading: 46%, read for 8 mins
-- 02 Oct 2019 17:46: reading: 48%, read for 3 mins
-- 02 Oct 2019 17:48: reading: 50%
-- 02 Oct 2019 17:52: reading: 52%, read for 4 mins
-- 02 Oct 2019 21:49: reading: 75%
-- 02 Oct 2019 21:50: reading: 76%, read for 29 mins
-- 05 Oct 2019 11:56: reading: 86%, read for 14 mins
-- 05 Oct 2019 13:50: reading: 90%
-- 05 Oct 2019 14:00: reading: 100%, read for 19 mins
-- 05 Oct 2019 14:00: finished, total time spent 200 mins

as a backup tool

kobuddy backup --help
usage: kobuddy backup [-h] [--label LABEL] path

You can run it via cron, for example every minute. When you connect your device via USB, the database will be backed up.

: * * * * * kobuddy backup /path/to/backups/kobo/

Alternatively, you can add a udev rule or something similar.

positional arguments:
  path           target directory or file to dump the database

optional arguments:
  -h, --help     show this help message and exit
  --label LABEL  device label (check lsblk if default doesn't work)

as a library

import kobuddy
kobuddy.set_databases('/L/backups/kobo/')
return kobuddy.get_books()[8: 10]
[Blindsight by Peter Watts, Classical Mechanics by John C. Baez & Derek K. Wise]

You can also find some examples in Orger or my package.

If you are looking for some specific Kobo events, check out EventTbl class, there is a good chance it’s been reverse engineered.

Related projects/services