During develop
LubimyCzytac [Metadata Source Plugin] in config I allow to download number of pages and save to comment and/or as identifier "lcpages" (abbreviation from "LubimyCzytac pages").
Now I prepared auxiliary plugin named "LCpages" [GUI plugin].
Plugin move number of pages value from "lcpages" identifier to custom column (for example "#pages"). This option works as intended and rapidly.
Code:
Spoiler:
Code:
def action_lcpages(self):
if not self.is_library_selected:
return error_dialog(self.gui, _('No selected book'),
_('No book selected for move LCpages to custom column'), show=True)
return
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 for move LCpages to custom column'), show=True)
book_ids = self.gui.library_view.get_selected_ids()
any_valid, colforpages = self._get_column_validity(cfg.KEY_PAGES_CUSTOM_COLUMN)
if not any_valid:
if not question_dialog(self.gui, _('Configure plugin'), '<p>'+
_('You must specify custom columns first. Do you want to configure this now?'),
show_copy_button=False):
return
self.show_configuration()
return
col_pag = colforpages
overwrite_pages = self._is_overwrite_pages(cfg.OVERWRITE_PAGES)
self.dzialaj_lcpages(book_ids, col_pag, overwrite_pages)
def dzialaj_lcpages(self, book_ids, col_pag, overwrite_pages):
dbA = self.gui.current_db
db = self.gui.current_db.new_api
id_aux = {}
for id in book_ids:
identifiers = dbA.get_identifiers(id, index_is_id=True)
id_aux[id] = identifiers.get('lcpages', None)
mi = dbA.get_metadata(id, index_is_id=True, get_cover=False)
pagesval = mi.get(col_pag)
if id_aux[id]:
if pagesval is not None:
if overwrite_pages:
db.set_field(col_pag, {id:id_aux[id]})
else:
db.set_field(col_pag, {id:id_aux[id]})
#Delete unnecessary identifier lcpages
deleteid = dbA.set_identifier(id,'lcpages', '')
self.gui.iactions['Edit Metadata'].refresh_gui(book_ids, covers_changed=False)
I would like to start fetch/download metadata from LubimyCzytac source (by LubimyCzytac plugin of course),
and next run standard primary function (move value from identifier to custom column).
I can call "Edit Metadata" window:
Code:
def edycjametadanych(self):
from calibre.library import db
from calibre.gui2.metadata.single import edit_metadata
db = db()
row_list = list(range(len(db.data)))
edit_metadata(db, row_list, 0)
I can call "LubimyCzytac" config:
Code:
def _configure_lubimyczytac(self):
from calibre.customize.ui import initialized_plugins
for plugin in initialized_plugins():
if plugin.name == 'LubimyCzytac':
if not plugin.is_customizable():
return info_dialog(self, _('Plugin not customizable'),
_('Plugin: %s does not need customization')%plugin.name, show=True)
from calibre.customize import InterfaceActionBase
if isinstance(plugin, InterfaceActionBase) and not getattr(plugin,
'actual_iaction_plugin_loaded', False):
return error_dialog(self, _('Must restart'),
_('You must restart calibre before you can'
' configure the <b>%s</b> plugin')%plugin.name, show=True)
plugin.do_user_config(self.parent())
Unfortunately, I can not call the fetch/download metadata by using LubimyCzytac plugin. I've read various threads about calling plugins from other plugins. I was trying for many hours - without success.
Is possible call fetch/download metadata from GUI plugin and next run other functions?
Code:
My plan:
1. Download metadata
2. Move value from ID to custom column
3. Delete ID
I would also like to check whether LubimyCzytac is enabled as a source of metadata.
Does my concept make sense?
PS. Count Pages plugin supporting LubimyCzytac (thx davidfor) is OK, but I want to test my own solution – only for speed fill custom column once downloaded value.