• This repository has been archived on 18/Aug/2018
  • Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python tool to export annotations and highlights from a Kobo SQLite file.

export-kobo

A Python tool to export annotations and highlights from a Kobo SQLite file.

Usage

$ # print all annotations and highlights to stdout
$ python export-kobo.py KoboReader.sqlite

$ # print the help
$ python export-kobo.py --help

$ # export to file instead of stdout
$ python export-kobo.py KoboReader.sqlite --output /path/to/out.txt

$ # export in CSV format
$ python export-kobo.py KoboReader.sqlite --csv

$ # export in CSV format to file
$ python export-kobo.py KoboReader.sqlite --csv --output /path/to/out.csv

$ # export in Kindle My Clippings format
$ python export-kobo.py KoboReader.sqlite --kindle

$ # export in Kindle My Clippings to file
$ python export-kobo.py KoboReader.sqlite --kindle --output /path/to/out.csv

$ # export annotations only
$ python export-kobo.py KoboReader.sqlite --annotations-only

$ # export highlights only
$ python export-kobo.py KoboReader.sqlite --highlights-only

$ # export as CSV to file annotations only
$ python export-kobo.py KoboReader.sqlite --csv  --annotations-only --output /path/to/out.txt

$ # print the list of books with annotations or highlights to stdout
$ python export-kobo.py KoboReader.sqlite --list

$ # as above, but export to file
$ python export-kobo.py KoboReader.sqlite --list --output /path/to/out.txt

$ # as above, but export in CSV format
$ python export-kobo.py KoboReader.sqlite --list --csv --output /path/to/out.txt

$ # export annotations and highlights for the book "Alice in Wonderland"
$ python export-kobo.py KoboReader.sqlite --book "Alice in Wonderland"

$ # as above, assuming "Alice in Wonderland" has ID "12" in the list printed by --list
$ python export-kobo.py KoboReader.sqlite --bookid 12

Installation

If you are a Windows user and you need help with Python, please follow this step-by-step guide.

Installing export-kobo is relatively simple:

  1. Install Python, 3.x (recommended), or 2.7.x, and make sure you have the python command available in your shell;

  2. Clone this repository:

    $ git clone https://github.com/pettarin/export-kobo

    or manually download the ZIP file from the Releases tab and unzip it somewhere;

  3. Enter the directory where export-kobo.py is:

    $ cd export-kobo
  4. Copy in the same directory the KoboReader.sqlite file from the .kobo/ hidden directory of the USB drive that appears when you plug your Kobo device to the USB port of your PC. You might need to enable the View hidden files option in your file manager to see the hidden directory;

  5. Now you can run the script as explained above, for example:

    $ python export-kobo.py KoboReader.sqlite

NOTE (2018-02-28): Frederic Da Vitoria confirms that the export script also works if you have the Kobo application for Windows PC. In this case the database file is called Kobo.sqlite and is located in the directory C:\Users\[your user name]\AppData\Local\Kobo\Kobo Desktop Edition\.

Troubleshooting

I am on Windows, but I do not know how to install Python

You can find a complete step-by-step guide to install Python and run export-kobo at the following URL: https://github.com/pettarin/python-on-windows

I am on Windows, and I get this error: python is not recognized as an internal or external command, operable program or batch file

Make sure you installed Python for your current user (e.g., check the Install for all users option in the Python installer), and that the directory containing the python.exe executable is in your PATH environment variable (e.g., check the Add Python to my PATH option in the Python installer).

If you have already installed Python, but it is not in your PATH, see this page for directions to solve this issue.

I got lots of question marks (?) in my output

If you are using Python 2.7.x, try switching to Python 3.x, which has saner support for Unicode characters.

You might also want to use the --output FILE switch to output to file instead of printing to standard output.

I ran the script, but I obtained too much data

If you want to output annotations or highlights for a single book, you can use the --list option to list all books with annotations or highlights, and then use --book or --bookid to export only those you are interested in:

$ python export-kobo.py KoboReader.sqlite --list
ID  Title
1   Alice in Wonderland
2   Moby Dick
3   Sonnets
...

$ python export-kobo.py KoboReader.sqlite --book "Alice in Wonderland"
...
$ python export-kobo.py KoboReader.sqlite --bookid 1
...

Alternatively, you can export to a CSV file with --csv --output FILE and then open the resulting output file with a spreadsheet application, disregarding the annotations/highlights you are not interested in:

$ python export-kobo.py KoboReader.sqlite --csv --output notes.csv
$ libreoffice notes.csv

I filtered my notes by book title with --book, but I got no results

Check that you wrote the book title exactly as printed by --list (e.g., copy-and-paste it), or use --bookid instead.

Notes

  1. Around May 2016 Kobo changed the schema of their KoboReader.sqlite database with a firmware update. The export-kobo.py script in the main directory of this repository works for this new database schema. If you still have an old firmware on your Kobo, and hence the old database schema, you might want to use one of the scripts in the old/ directory. Note, however, that those scripts are very old, possibly buggy, and they are no longer supported (old Web page).

  2. Since I no longer use a Kobo eReader, this project is maintained in "legacy mode". Changes to the schema of the KoboReader.sqlite database can be reflected on the code only thanks to users sending me their KoboReader.sqlite file, for me to study its schema.

  3. Bear in mind that no official specifications are published by Kobo, hence the script works as far as my understanding of the database structure of KoboReader.sqlite is correct, and its schema remains the same.

  4. Although the KoboReader.sqlite file is opened in read-only mode, it is advisable to make a copy of it on your PC and export your notes from this copy, instead of directly accessing the file on your Kobo eReader device.

Acknowledgments

  • Chris Krycho contributed a fix for a typo in month names.
  • Pierre-Arnaud Rabier suggested adding an option to extract the annotations and highlights for a single ebook.
  • Nick Kalogirou and Andrea Moro provided me with theirs KoboReader.sqlite file with the new schema.
  • Curiositry suggested adding an option to extract in Kindle My Clippings format.
  • Frederic Da Vitoria confirmed that the export script works for the Kobo app for Desktop PC.
  • Matthieu Nantern contributed the raw export mode.

License

export-kobo is released under the MIT License.

More Repositories

1

forced-alignment-tools

A collection of links and notes on forced alignment tools
Python
858
star
2

epub3reader

EPUB3Reader Android App
Java
229
star
3

penelope

Penelope is a multi-tool for creating, editing and converting dictionaries, especially for eReader devices
Python
200
star
4

ipapy

ipapy is a Python module to work with International Phonetic Alphabet (IPA) strings
Python
80
star
5

glyphIgo

glyphIgo is a Swiss Army knife for dealing with fonts and EPUB eBooks
Python
75
star
6

asciicast2gif

asciicast2gif converts asciicast files to animated GIF files
HTML
39
star
7

setup-festival-mbrola

A Bash script for Linux and Mac OS X to download/compile/install Festival, MBROLA, and voice files.
Scheme
25
star
8

python-on-windows

A step-by-step guide on installing Python and using the Command Prompt for Windows
18
star
9

yael

yael (Yet Another EPUB Library) is a Python library for reading, manipulating, and writing EPUB 2/3 files
Python
17
star
10

fsfs3

Scripts to convert "Free Software, Free Society: Selected Essays of Richard M. Stallman, 3rd Edition" from Texinfo to EPUB and MOBI
HTML
16
star
11

rb_smil_emulator

This JavaScript enables the tap-to-play function on those platforms that do not properly support the EPUB 3 Media Overlay specification (most notably, Apple iBooks).
JavaScript
12
star
12

icarus

icarus is a Sigil plugin to create EPUB 3 Audio-eBooks
Python
12
star
13

nvdb

A Python script to extract the plain-text data from the NVdB PDF file.
Python
8
star
14

wiktts

Mining MediaWiki dumps to create better TTS engines (using Machine Learning)
Python
5
star
15

elzzur

elzzur solves a Ruzzle board, listing all the valid words with their score
Python
5
star
16

espeakng.js-cdn

CDN files for espeakng.js, the Javascript port of eSpeak-ng TTS
JavaScript
5
star
17

Pushover-game

Mirror of the sf repo of the reimplementation of the Pushover puzzle game (Ocean, 1992)
Shell
4
star
18

ink2fxl

ink2fxl converts Inkscape SVG files to XHTML+(SVG)+CSS, XHTML+raster (layer-wise), or raster-only (layer-wise).
Python
4
star
19

exlibris

exlibris is a tool for adding an ex libris to EPUB eBooks, available as a CLI tool, a GUI tool, and Calibre plugin.
Python
3
star
20

espeakosx

A simple Bash script to compile eSpeak on Mac OS X
Shell
2
star
21

awesome-config

My configuration file and theme for the awesome desktop manager
Lua
1
star