01-19-2017, 01:25 PM | #1 |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
Importing books via command line *in the background*?
Hello,
I've been using a shell script on OS X to import ebooks using the command line tool like this: imp="$CALIBREDIR/calibre $BOOKDIR/$book" eval "$imp" This works, but Calibre jumps to its front to do the import process. When importing a number of books it renders the computer unusable until all the imports are done. Is there any way to tell Calibre to do its import in the background so this all happens silently? |
01-19-2017, 03:46 PM | #2 |
null operator (he/him)
Posts: 20,568
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@mrowz - How about using the calibredb add command, see ==>> Command Line Interface
I am not a MAC user so I'm assuming the CL utilities work similar under OSX as they do on Linux and Windows - i.e. no GUI. BR |
01-19-2017, 06:50 PM | #3 |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
Thanks for the reply... that command does add the book silently like I want, but the imported book doesn't have the cover for some reason.
When I add the book through the GUI or through the original command the cover shows up as expected. calibredb add has an option -c for a cover file, but these books don't have external cover images. Any idea how I can get this last part to work? |
01-19-2017, 09:07 PM | #4 |
null operator (he/him)
Posts: 20,568
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
01-20-2017, 01:37 PM | #5 |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
Hmm... is there any way to do that programmatically?
There's the ebook-meta tool, but it doesn't seem to be able to do what you just described. It can set the cover from a file but not from the book itself according to the description: https://manual.calibre-ebook.com/gen...book-meta.html |
01-20-2017, 03:38 PM | #6 |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
Filed an enhancement request on the bug tracker.
From the command line there's only a way to add the cover from a file, but not a way to add the cover from the ebook itself. I tried using ebook-meta to save the cover from the ebook, but it said "no cover found" even though there is a cover that shows up just fine when imported through the GUI. Ideally "calibredb add" would function just as well as adding through the GUI without me having to set any other options. Barring that, it would be nice to be able to set the cover from the ebook file via the command line. |
01-22-2017, 03:26 PM | #7 | |
Zealot
Posts: 119
Karma: 64428
Join Date: Aug 2011
Device: none
|
Quote:
|
|
01-22-2017, 05:32 PM | #8 | |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
Quote:
|
|
01-22-2017, 05:34 PM | #9 | |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
And here's my reply from development:
Quote:
|
|
01-23-2017, 01:10 PM | #10 |
Zealot
Posts: 119
Karma: 64428
Join Date: Aug 2011
Device: none
|
Here's another thing to consider: Does OSX support multiple virtual terminals or multiple windows or multiple desktops or something like that? If so, start your shell script in one terminal/window/desktop/whatever and switch to another to do a different terminal session.
|
04-20-2017, 12:33 PM | #11 |
Junior Member
Posts: 5
Karma: 10
Join Date: Jul 2011
Device: iPad
|
Have you considered adding ebook-meta $book --get-cover into your workflow? Would need to pipe the output cover file back into your script to import it though...
|
05-22-2017, 07:30 PM | #12 |
Member
Posts: 22
Karma: 10
Join Date: Sep 2015
Device: iPad Mini/iPhone 6
|
|
05-26-2017, 11:30 AM | #13 |
Junior Member
Posts: 5
Karma: 10
Join Date: Jul 2011
Device: iPad
|
Ahhhh, sorry, I didn't catch that. If the problem is that a cover isn't declared then perhaps you could have your script find it.
Here are some other options I can think of: - convert the book to HTML using the ebook-convert commandline and then look in the /images directory for *cover*.jpg/png/gif or the first numbered image and use that image with ebook-meta - unzip the book or unzip all images from the book into a temporary directory "unzip testbook.epub *.jpg *.png *.gif ...etc" into a temporary directory then parse and pipe back into ebook-meta Depending on your book source, you might have to do some digging into the structure of the epubs to see what the covers are named and if they are in subfolders (cover/images/...) to get some reliable results. You also might want to look at this python epub-thumbnailer script for some inspiration. If you look at the script source it shows some good options for finding the cover file. Good luck! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
View books from command line | nichtleiter | Calibre | 3 | 12-20-2013 03:05 PM |
Adding custom fields when importing books via command line | chemi | Library Management | 7 | 02-25-2013 10:16 PM |
Adding books from command line | chemi | Library Management | 3 | 02-25-2013 11:28 AM |
How to use the command line to move books | jorm | Development | 0 | 04-03-2012 02:22 PM |
Checking and Importing from the Command Line | markbond1007 | Calibre | 3 | 08-06-2009 12:46 PM |