ebk-export
To export the list of books stored in your library along with their metadata,
run ebk-export and redirect the output to a file:
ebk-export -l /path/to/library > data.json
Output structure
The JSON document sent to stdout has a top-level key “Books”, mapping to an array of records for each book:
{ "Books": [ {...}, {...} ] }
The book records contain:
- metadata fields, such as “Title” and “Authors”;
- the path to the book directory, relative to the library root;
- the name of the cover image file, if there is one; and
- the list of e-book files for that book.
{
"Title": "The Odyssey",
"Authors": [ "Homer", "Samuel Butler" ],
"Date": 1898,
...,
"Path": "Homer/The Odyssey (3)"
"Cover": "cover.jpg",
"Files": [
"/path/to/library/Homer/The Odyssey (3)/The Odyssey - Homer.epub"
],
}
Querying the exported data
The exported JSON document can be filtered using jq.
For example, to print the title and list of authors for each book:
ebk-export | jq '.Books[] | [.Title, (.Authors | join(", "))] | join("; ")'
"Blood of Elves; Andrzej Sapkowski" "Insectivorous Plants; Charles Darwin" "The Odyssey; Homer, Samuel Butler" "Alice's Adventures in Wonderland; Lewis Carroll" "Through the Looking-Glass; Lewis Carroll"
Or to select only books published by Project Gutenberg,
and pipe the corresponding EPUB files to fzf for interactive selection:
query='.Books[] | select(.Publisher | contains("Gutenberg"))'
query=$query' | .Files[] | select(endswith(".epub"))'
ebk-export | jq "$query" | fzf
"/path/to/library/.../.../Insectivorous Plants - Charles Darwin.epub"