|
|
Thread Tools | Search this Thread |
12-20-2020, 03:55 PM | #1 |
Member
Posts: 10
Karma: 10
Join Date: Apr 2020
Device: iPad Pro 2018
|
How to use python/shell scripts to edit the metadata of selected book(s) in calibre?
It seems to me calibre has made good use of python for many purposes. So I'm wondering it there is a way to edit the metadata, e.g. adding tags, of selected book(s) in calibre window using python script?
I know I can simply click "Edit Metadata" and use the interface to edit metadata but I'm here looking for a way of automation. (I'm using calibre on macOS and with applications like Keyboard Maestro or Alfred I can set a bunch of keyboard shortcuts to automate this process.) Any help will be appreciated! |
12-20-2020, 05:17 PM | #2 |
Grand Sorcerer
Posts: 12,936
Karma: 76440364
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
See if https://manual.calibre-ebook.com/gen...cli-index.html gives you ideas
|
12-20-2020, 05:52 PM | #3 |
Wizard
Posts: 1,267
Karma: 10203040
Join Date: Dec 2011
Device: a variety (mostly kindles and kobos)
|
Can you elaborate on what type of edits you want to automate?
I have a couple of shell scripts I use but they are interactive - they prompt for values to put in certain fields. I mostly use calibredb set_metadata or calibredb set_custom. If you want to call your script from the calibre window though that implies writing a plugin I think. Unless Keyboard Maestro or Alfred can do screen scraping as well as provide hot keys. Because you would need a way to "read" the values associated with the current book and act upon it. |
12-20-2020, 06:35 PM | #4 |
Wizard
Posts: 1,141
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
|
Have a look at the Action Chains plugin and see whether it fulfills your needs. It also enables you to write python scripts by using the plugin's module editor to create custom actions. The advantage to this approach to the usual calibre-debug pyhton scripts is that it can read selections from gui and act on them.
For more on using python for calibre development, see the documentation here. |
12-20-2020, 07:18 PM | #5 |
Member
Posts: 10
Karma: 10
Join Date: Apr 2020
Device: iPad Pro 2018
|
I'd like to perform the following actions:
1. Changing the Rating of currently selected book(s) with a hotkey, such as ⌘+1/2/3/4/5 for corresponding ratings. 2. Adding or switching between "Unread/Read/Reading" tags to currently selected book(s). 3. Obtaining the book name or author name and search it with a search engine. Now I have to click on the author name, copy it and paste on Google search bar. I want to use a python/shell script to automate this procedure. 4. ... I can give more examples here but the fundamental idea is to manipulate the metadata (both original columns or custom columns) without using the Edit Metadata interface but with a python/shell script which is capable of reading/writing the metadata of CURRENTLY SELECTED book(s). |
12-20-2020, 07:49 PM | #6 |
Custom User Title
Posts: 9,812
Karma: 68360983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
1 be done from the book list with relatively few keystrokes. See the doubleclick_on_library_view tweak for more information.
2 can be action chained pretty easily. I have a 'mark as read' that sets #read:true, #percentread:100, #lastread: current time and pops up the rating dialog. For 3 there's a plugin called Search the Internet though I don't remember if that can be hotkeyed. |
12-20-2020, 08:02 PM | #7 | |
Wizard
Posts: 1,141
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
|
Quote:
No. 3 can be done by writing An action chains custom action, if you know python. |
|
12-20-2020, 10:17 PM | #8 | |
Member
Posts: 10
Karma: 10
Join Date: Apr 2020
Device: iPad Pro 2018
|
Quote:
|
|
12-20-2020, 10:19 PM | #9 | |
Member
Posts: 10
Karma: 10
Join Date: Apr 2020
Device: iPad Pro 2018
|
Quote:
|
|
Tags |
automation, python |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre:Book Cover size in Book Details side pane & Edit Metadata Individually window | Volfer | Calibre | 3 | 01-05-2016 02:56 PM |
Selected a couple of Authors/Series but Calibre not showing the books selected | lizzyong | Library Management | 3 | 04-16-2015 08:47 PM |
Quick util to wait for press (in shell or python) | krcrouse | Kindle Developer's Corner | 3 | 01-21-2014 02:02 AM |
The Idiot's Guide to running Igorsk's Python Scripts | Nate the great | Workshop | 9 | 05-22-2010 01:17 PM |
GUI Frontend for python scripts [windows] - seeking mod input first | sherman | Workshop | 7 | 04-27-2009 02:04 AM |