Metadata-Version: 2.4
Name: kobuddy
Version: 0.6.20260724
Summary: Backup and extract data from your Kobo reader
Project-URL: Homepage, https://github.com/karlicoss/kobuddy
Author-email: "Dima Gerasimov (@karlicoss)" <karlicoss@gmail.com>
Maintainer-email: "Dima Gerasimov (@karlicoss)" <karlicoss@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Dmitrii Gerasimov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.12
Description-Content-Type: text/plain

# -*- org-confirm-babel-evaluate: nil; -*-

#+begin_src python :exports results :results drawer :dir src
import kobuddy
return kobuddy.__doc__
#+end_src

#+RESULTS:
:results:

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.
:end:

* Installing
From pypi: ~pip3 install --user kobuddy~

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

* Usage
  
#+begin_src bash  :exports both :results scalar
kobuddy --help
#+end_src

#+RESULTS:
#+begin_example
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
#+end_example

** as a standalone app
Example of printing reading progress:

#+begin_src bash :exports source
kobuddy --db /L/backups/kobo progress
#+end_src

#+begin_example
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
#+end_example

** as a backup tool
#+begin_src bash  :exports both :results scalar
kobuddy backup --help
#+end_src

#+RESULTS:
#+begin_example
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)
#+end_example

** as a library

#+begin_src python :exports both :results value scalar :dir src
  import kobuddy
  kobuddy.set_databases('/L/backups/kobo/')
  return kobuddy.get_books()[8: 10]

#+end_src

#+RESULTS:
: [Blindsight by Peter Watts, Classical Mechanics by John C. Baez & Derek K. Wise]


You can also find [[https://github.com/karlicoss/orger/blob/master/modules/kobo2org.py][some]] [[https://github.com/karlicoss/orger/blob/master/modules/kobo.py][examples]] in Orger or [[https://github.com/karlicoss/my/blob/master/my/books/kobo.py][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
- [[https://github.com/pettarin/export-kobo][export-kobo]]: only processes annotations from a single database
- [[https://www.thekobonotes.com]]: closed source; you have to upload database manually, however it does display them as a nice html
