10-25-2016, 01:15 PM | #1 |
Junior Member
Posts: 2
Karma: 10
Join Date: Oct 2016
Device: none
|
Read custom fields from metadata plugin
Hello,
I'd like to read the value of a custom field (coming from a custom column) from a metadata download plugin. Is this possible? If yes, can you please post some example code? Last edited by Manitu80; 10-25-2016 at 01:51 PM. |
10-25-2016, 09:56 PM | #2 |
creator of calibre
Posts: 44,372
Karma: 23764838
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, metadata plugins run in a separate thread and have no access to the database. The only metadata that is made available to them is title, authors and identifiers.
|
Advert | |
|
10-26-2016, 03:21 PM | #3 |
Junior Member
Posts: 2
Karma: 10
Join Date: Oct 2016
Device: none
|
Thank you Kovid for the answer.
One option is to save the data from my custom column into an identifier (by using a GUI plugin), and than to pick it up from the identifier in my metadata download plugin. For example: In the gui plugin: Code:
rows = self.gui.library_view.selectionModel().selectedRows() if not rows or len(rows) == 0 : return error_dialog(self.gui, _('No selected book'), _('No book selected'), show=True) db = self.gui.current_db book_ids = self.gui.library_view.get_selected_ids() for id in book_ids: mi = db.get_metadata (id, index_is_id=True, get_cover=False) mi.set_identifier('id_title_orig', mi.get("#title_orig")) Code:
def identify(self, log, result_queue, abort, title=None, authors=None, identifiers={}, timeout=30): # ... title_orig = identifiers.get('id_title_orig', None) if title_orig: title=title_orig Now I have another question: How can I chain the execution of the 2 plugins above? It is possible to start the execution of the metadata download plugin from a GUI plugin (and to wait for execution finish)? Thank you and best regards |
10-26-2016, 10:59 PM | #4 |
creator of calibre
Posts: 44,372
Karma: 23764838
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yes, you can. You can call the functions from any plugin via the gui.iactions['plugin name'] object which is a reference to the plugin object.
|
Tags |
custom field, metadata plugin |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access custom fields from metadata DB | JupiterJones | Development | 2 | 10-22-2014 07:48 AM |
Adding custom fields to the main UI | karimnaguib | Library Management | 5 | 10-06-2013 09:27 PM |
Getting custom metadata field in GUI plugin | SauliusP. | Development | 7 | 02-11-2012 01:31 AM |
question on custom fields | Keltari | Library Management | 5 | 08-26-2011 02:58 PM |
Catalogs & Custom Fields | nynaevelan | Library Management | 14 | 10-27-2010 04:55 PM |