dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit b04ca781fded34b9cff225be9febfe2e2f0bfc73
parent 32c57b59db360daecbfdacfa1188c09bdc632588
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Wed,  6 Jan 2021 23:54:42 +0100

pocketbook-notes: initial script to export notes from pocketbook

Database is generally located in /system/**/books.db in main memory.

Diffstat:
Ascripts/pocketbook-notes | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/scripts/pocketbook-notes b/scripts/pocketbook-notes @@ -0,0 +1,21 @@ +#!/bin/sh +die() { printf "%s\n" "$1" >&2 && exit 1; } + +for dep in 'sqlite3' 'sed' 'jq'; do + command -v "$dep" >/dev/null 2>&1 || die "Error: $dep not installed." +done +[ $# -eq 2 ] || die "Usage: pocketbook-notes /path/to/books.db '%wildcarded%book%title%'" +books_db="$1" +[ -f "$books_db" ] || die "Couldn't read $books_db." +title_wild="$2" + +# to grep a whole DB, do: `sqlite3 <filename> .dump | grep -i 'whatever'` +sqlite3 "$books_db" \ + "select Tags.Val + from items join tags on (Items.OID = Tags.ItemID) + where Items.ParentID = (select OID from Books where Title like '$title_wild') + and TypeId = (select OID from TypeNames where TypeName = 'obj.book_mark') + and TagId = (select OID from TagNames where TagName = 'bm.quotation');" \ + | sed '$!s/$/,/; 1s/^/[/; $s/$/]/' \ + | jq -r '.[].text' \ + | sed 's/^/* /'+ \ No newline at end of file