08-14-2008, 06:30 PM | #1 |
Junior Member
Posts: 5
Karma: 10
Join Date: Jul 2008
Device: PRS-505
|
<Command Line> Add multiple books in multiple formats
I have a fairly extensive ebook Library. Some of my books are in multiple formats. I'd like to be able to from the commandline add books to the calibre database like. "AddBook2DB TomSawyer.lrf TomSawyer.zip TomSayer.mobi"
Is there a good way to do this? -Joe |
08-14-2008, 06:43 PM | #2 |
creator of calibre
Posts: 44,569
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
calibredb --help
|
Advert | |
|
09-25-2010, 03:29 PM | #3 |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: iPod
|
Sorry to revive an old thread, but I'd like to keep the context of what's already been said.
According to calibredb --help, you can either add duplicates (and have to clean it up using merge from the gui later), or add by unique title, skipping files of the same title in a new format. There doesn't appear to be a way to add new formats to an existing book from the command line (no command line merge function either). Am I missing something, or has someone hacked up a script that will accomplish this? Do I have to rip apart a few plugins to create a command line script to do this? I have found adding by command line to be orders of magnitude faster than using the GUI (either via interface or by dragging books over the window -- my preferred method). What I'd really like to do is write a script that traverses a directory structure, verifies that my to-be-imported books have the correct naming format to be imported correctly, and then imports all of those books, correctly merging books with the same author and title. After this, the script would then trigger mekk's ISBN detection script, and after that would trigger the gui-style download metadata script. Right now, this does not seem possible without scripting the GUI itself (which seems a bit backward, as the GUI is generated by scripts in the first place). Thoughts? Ideas? |
09-25-2010, 03:42 PM | #4 |
creator of calibre
Posts: 44,569
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
calibredb add_format -h
|
09-25-2010, 03:43 PM | #5 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
As to "verifies that my to-be-imported books have the correct naming format to be imported correctly," if you can code this, it would be useful for the GUI, too. I'm not sure how you tell a title, from a series, from an author. |
|
Advert | |
|
09-25-2010, 04:23 PM | #6 |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: iPod
|
Kovidgoyal, add_format won't work unless I already have an ID. I suppose I could re-write everything from scratch and do a loop (lookup to see if book already exists, grab ID if it does and add_format, otherwise just run add), but since all the code is already written and used by the GUI, that seems a bit too much effort.
Thanks, Starson17; that points me exactly where I want to go. I was actually hoping you'd respond to this I plan to identify the merge records by parsing the following tree: Code:
Check for Title If exists, Check for author If exists, Check for format If exists, end else get book ID merge books else add book As for the "correct naming format", all this test would do is verify that the RE I use properly captures all the expected fields. If everything ends up in the Title field, I know the RE failed and the book file name needs a look before that book gets imported. I could also apply normalization (eg. JRR Tolkien, J.R.R. Tolkien, J. R. R. Tolkien, and Bob Smith, Bob R. Smith, Bob Smith, Jr.) and ensure things like Jr, Esq, Sir, Mr, etc. get handled appropriately by author_sort. Next time I have a moment, I'll try to write some of these generically in Python so I can use them on the command line but also have available for someone to port to the GUI who is more heavily involved (I don't have much spare time, which is why I'm trying to avoid duplicating effort). |
09-25-2010, 04:30 PM | #7 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: iPod
|
Quote:
|
|
09-25-2010, 06:39 PM | #8 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
That code is used in add.py (line 159) to do the autosort/automerge work. I was a bit confused by your comment that there was "no command line merge function" as I couldn't see many situations where you'd know the books to be merged outside of the GUI (i.e. how you would know the ID, other than by writing code to search for books to be merged.) I can see where you'd like the autosort/automerge of new formats into existing records, however. |
|
09-26-2010, 12:07 AM | #9 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: iPod
|
Quote:
both return the ID, which then gets piped into the merge. You can also parse it so that you select your base ID as the top result from hits that contains ISBN, then publisher, and then book type in order of preference. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Content Can I add multiple books to a collection | mike_bike_kite | Amazon Kindle | 5 | 04-11-2021 08:21 AM |
Bug: entries with multiple formats trigger multiple conversions | flinx1 | Calibre | 12 | 05-21-2010 07:23 AM |
How can I add multiple formats (without converting) and have Calibre see them? | strannik | Calibre | 4 | 02-03-2010 06:49 PM |
Multiple formats - What gets sent | edbro | Calibre | 2 | 01-20-2010 09:38 PM |
Duplicate books - multiple formats | mranlett | Calibre | 5 | 09-26-2009 08:02 AM |