Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 05-07-2018, 11:48 AM   #1
rpspringuel
Enthusiast
rpspringuel began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Feb 2014
Device: Kindle 4
Luanch Calibre with particular book selected

Is there a way to launch Calibre (from the command line) so that a particular book (which is already in the library) is selected? Or alternatively with a particular set of search results already displayed? Ideally the method should simply change the book selected (or search results displayed) if Calibre is already running. I do not want to trigger the add book routines as I know that the target book is already in my library when I want to do this.

Some context (for those interested): I'm on a Mac and I make use of BibDesk for citation purposes and would like to create a file link between a BibDesk entry and an ebook in Calibre. Obviously I cannot permit both programs to manage the actual location of a real file, so I'm creating Automator Apps which use a simple shell script to connect to the ebook. BibDesk can thus control the location of the Automator App while Calibre retains control over the ebook itself. Right now my Automator Apps launch the ebook-viewer directly, which requires the full path to the book (and thus is subject to breakage should Calibre ever move the book) and leaves me hanging when I need to do anything other than read the book (like say, edit it) because the reader has no links back to the main program (or to any of the other tools, like the editor). I thus would much prefer a way to launch the main Calibre program and have it point to the book.
rpspringuel is offline   Reply With Quote
Old 05-07-2018, 12:32 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 33,216
Karma: 10205092
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There's no way to open calibre pointing to a particular book, but you can get the full path to a book using the calibredb command line tool

calibredb list -f formats -s id:1234

See the entry for calibredb in the user manual for more details
kovidgoyal is offline   Reply With Quote
Old 05-07-2018, 02:14 PM   #3
rpspringuel
Enthusiast
rpspringuel began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Feb 2014
Device: Kindle 4
That doesn't work if calibre is already running: an error about the danger in having two programs which are capable of changing the database running at once is raised. I understand that having two programs changing the database at the same time is a problem, but a simple search to retrieve information from the database shouldn't change anything. Is there a way for the search functionality of `calibredb` (particularly the `list` and `search` tools) to be used while calibre is running?
rpspringuel is offline   Reply With Quote
Old 05-07-2018, 02:54 PM   #4
rpspringuel
Enthusiast
rpspringuel began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Feb 2014
Device: Kindle 4
Further question: If the book has multiple formats, is there a way to limit which format is retrieved?
rpspringuel is offline   Reply With Quote
Old 05-07-2018, 09:58 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 33,216
Karma: 10205092
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Turn on the calibre content server iin the calibre GUI and connect to that via calibredb, see the manual page for details.

No there's no way to limit which format is retrieved, but you can easily post process the returned list (use the --for-machine flag to has calibredb output the data in json format for easy processing).
kovidgoyal is offline   Reply With Quote
Old 05-08-2018, 11:52 AM   #6
rpspringuel
Enthusiast
rpspringuel began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Feb 2014
Device: Kindle 4
Quote:
Turn on the calibre content server iin the calibre GUI and connect to that via calibredb, see the manual page for details.
When I try this I don't get full paths returned, just the kinds of the formats. Example:

Code:
$ calibredb list -f formats -s id:630 --for-machine --with-library "http://127.0.0.1:8080"
[
  {
    "formats": [
      "AZW3", 
      "HTMLZ"
    ], 
    "id": 630
  }
]
Am I missing something that would allow those to be full paths instead?
rpspringuel is offline   Reply With Quote
Old 05-08-2018, 12:20 PM   #7
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 10,312
Karma: 60928025
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Glo HD, Touch, Tolino EPOS
I wouldn't be surprised if the path info was not returned because you are connecting to a server.

Sent from my Nexus 7 using Tapatalk
PeterT is offline   Reply With Quote
Old 05-08-2018, 01:35 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 33,216
Karma: 10205092
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah the server wont get full path info as it has no concept of paths. But instead you can use calibredb export to copy the ebook file elsewhere and then launch it.
kovidgoyal is offline   Reply With Quote
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
why only koreader can't be luanch in kual potter.G Kindle Developer's Corner 6 06-08-2018 10:54 AM
Book List showing more than Selected Author Larla Calibre 3 08-13-2016 07:16 PM
Previous selected book when opening Calibre emoreau Calibre 3 07-27-2015 07:21 PM
Selected a couple of Authors/Series but Calibre not showing the books selected lizzyong Library Management 3 04-16-2015 07:47 PM
I want Calibre 64bit to only show the tag selected hola!claude Library Management 3 12-22-2014 05:14 AM


All times are GMT -4. The time now is 06:47 PM.


MobileRead.com is a privately owned, operated and funded community.