Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Jul 15, 2020
1 parent 08ad23e commit a59ceda
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 55 deletions.
81 changes: 42 additions & 39 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- org-confirm-babel-evaluate: nil; -*-

[[https://circleci.com/gh/karlicoss/orger/tree/master][https://circleci.com/gh/karlicoss/kobuddy/tree/master.svg?style=svg]]

#+begin_src python :exports results :results drawer :dir src
import kobuddy
return kobuddy.__doc__
Expand All @@ -14,47 +12,49 @@ Kobuddy is a tool to backup Kobo Reader sqlite database and extract useful thing

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

Tested on Kobo Aura One, however database format shouldn't be different on other devices.
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
~pip3 install --user .~
From pypi: ~pip3 install --user kobuddy~

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

* Usage

** as a standalone app
#+begin_src bash :exports both :results value scalar
./kobuddy --help
#+begin_src bash :exports both :results scalar
kobuddy --help
#+end_src

#+RESULTS:
#+begin_example
usage: __main__.py [-h] [--db DB] [--errors {throw,return}]
{books,progress,annotations} ...
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}
{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.
--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
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
kobuddy --db /L/backups/kobo progress
#+end_src

#+begin_example
Expand All @@ -77,8 +77,31 @@ Finished: 05 Oct 2019 14:00
-- 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/')
Expand All @@ -88,33 +111,13 @@ Finished: 05 Oct 2019 14:00

#+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.

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

#+RESULTS:
#+begin_example
usage: backup.py [-h] [--label LABEL] path

Backup tool for Kobo device database. You can run it via cron, e.g. every
minute and next time you connect you book via USB database would be backed up.
Potentially you could also add the script to udev rules.

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

* 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 nice html
- [[https://www.thekobonotes.com]]: closed source; you have to upload database manually, however it does display them as a nice html
4 changes: 0 additions & 4 deletions backup

This file was deleted.

17 changes: 13 additions & 4 deletions src/kobuddy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ def main():
setup_logger(logger, level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')


p = argparse.ArgumentParser(description="""
Fmt = lambda prog: argparse.RawTextHelpFormatter(prog, width=100)
p = argparse.ArgumentParser(
description="""
Library to parse and provide Python interface for your Kobo reader
""")
""",
formatter_class=Fmt,
)
p.add_argument('--db', type=Path, help='''
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.
Expand All @@ -37,10 +41,15 @@ def main():
sp.add_parser('books' , help='print all books')
sp.add_parser('progress' , help='print all book reading progress')
sp.add_parser('annotations', help='print all annotations (bookmarks/highlights/comments)')
bp = sp.add_parser('backup', help='run backup helper')
bp = sp.add_parser('backup', help='backup the database from your Kobo device', description='''
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.
''', formatter_class=Fmt)
import kobuddy.backup
kobuddy.backup.setup_parser(bp)
# TODO FIXME document..

args = p.parse_args()

Expand Down
9 changes: 1 addition & 8 deletions src/kobuddy/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ def setup_parser(p):


def main():
p = argparse.ArgumentParser(description='''
Backup tool for Kobo device database.
You can run it via cron, e.g. every minute and next time you connect you book via USB database would be backed up.
Potentially you could also add the script to udev rules.
''')
p = argparse.ArgumentParser()
setup_parser(p)
args = p.parse_args()
run(args)
Expand Down

0 comments on commit a59ceda

Please sign in to comment.