View Single Post
Old 05-08-2018, 04:29 PM   #9
rpspringuel
Enthusiast
rpspringuel began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Feb 2014
Device: Kindle 4
Okay, I think I've managed to put everything together to get a satisfactory result.

For those interested, I'm creating an Application using Automator which runs the following shell script:
Code:
book_search="#search string to find book#"

PATH=/Applications/calibre.app/Contents/console.app/Contents/MacOS/:$PATH
{
	book_id=$(calibredb search --limit 1 "$book_search")
	calibredb export --dont-save-cover --dont-update-metadata --dont-write-opf --formats azw3 --to-dir $TMPDIR --template "temp_book" $book_id
} || {
	book_id=$(calibredb search --limit 1 --with-library "http://127.0.0.1:8080" "$book_search")
	calibredb export --with-library "http://127.0.0.1:8080" --dont-save-cover --dont-update-metadata --dont-write-opf --formats azw3 --to-dir $TMPDIR --template "temp_book" $book_id
}

open -a ebook-viewer "$TMPDIR/temp_book.azw3"
Obviously the search string at the top needs to be changed to look for the book wanted. It's hard coded into the script because I create a new one for each book I'm looking to link like this.

It should also be noted, that even though the script is capable of handling both the case where the GUI is not open and the case where it is and the content server is running, it will fail if the GUI is open and the content server is not running. It is, therefore, recommended that you set you calibre preferences to start the content server automatically when the GUI is launched if you're going to do something similar.
rpspringuel is offline   Reply With Quote