Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 10-25-2016, 01:15 PM   #1
Manitu80
Junior Member
Manitu80 began at the beginning.
 
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.
Manitu80 is offline   Reply With Quote
Old 10-25-2016, 09:56 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: 43,843
Karma: 22666666
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.
kovidgoyal is offline   Reply With Quote
Old 10-26-2016, 03:21 PM   #3
Manitu80
Junior Member
Manitu80 began at the beginning.
 
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"))
In the metadata plugin:
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
I've tested the idea above and looks promising.

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
Manitu80 is offline   Reply With Quote
Old 10-26-2016, 10:59 PM   #4
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: 43,843
Karma: 22666666
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.
kovidgoyal is offline   Reply With Quote
Reply

Tags
custom field, metadata plugin


Forum Jump

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


All times are GMT -4. The time now is 11:04 AM.


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