![]() |
#1096 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That fixed it.
I must've accidentally deleted it while removing the reverted column-name tweak. (That explains why updating to 6.17 seemed to break it.) Last edited by ownedbycats; 04-29-2023 at 01:02 PM. |
![]() |
![]() |
![]() |
#1097 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Would it be possible to make a module that replicates the behaviour of the 'paste' button in the identifiers field?
|
![]() |
![]() |
![]() |
#1098 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
|
![]() |
![]() |
![]() |
#1099 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
The 'paste' button will convert the URL to an id if there's a rule for it. (The tooltip only mentions isbn and url but that's a mistake.) This would let me copy the link of a goodreads or fantasticfiction page from browser and then paste it without opening the MDE.
Last edited by ownedbycats; 05-10-2023 at 07:33 AM. |
![]() |
![]() |
![]() |
#1100 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
That is not something I would be interested in.
|
![]() |
![]() |
![]() |
#1101 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
python: def parse_clipboard_for_identifier(): from calibre.ebooks.metadata.sources.prefs import msprefs from calibre.utils.formatter import EvalFormatter from qt.core import QApplication import re text = str(QApplication.clipboard().text()).strip() if not text: return None rules = msprefs['id_link_rules'] if rules: formatter = EvalFormatter() vals = {'id' : '__ID_REGEX_PLACEHOLDER__'} for key in rules.keys(): rule = rules[key] for name, template in rule: try: url_pattern = formatter.safe_format(template, vals, '', vals) url_pattern = re.escape(url_pattern).replace('__ID_REGEX_PLACEHOLDER__', '(?P<new_id>.+)') if url_pattern.startswith('http:') or url_pattern.startswith('https:'): url_pattern = '(?:http|https):' + url_pattern.partition(':')[2] new_id = re.compile(url_pattern) new_id = new_id.search(text).group('new_id') if new_id: vals = {} vals[key] = new_id return vals except Exception: import traceback traceback.print_exc() continue from calibre.customize.ui import all_metadata_plugins for plugin in all_metadata_plugins(): try: identifier = plugin.id_from_url(text) if identifier: vals = {} vals[identifier[0]] = identifier[1] return vals except Exception: pass return None def evaluate(book, context): x = parse_clipboard_for_identifier() if x: return ', '.join(k + ':' + v for k,v in x.items()) return '' |
|
![]() |
![]() |
![]() |
#1102 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Thanks. Copies to clipboard works
![]() Is there a way to pass the clipboard contents to a SFE? I was thinking maybe a chain variable. Or maybe I can just add the template itself to the variable. EDIT: To add directly, I put the template in a variable called copied_id and then used this: Code:
program: newid = globals(copied_id); list_union(newid, $identifiers, ',') Last edited by ownedbycats; 05-11-2023 at 10:58 AM. |
![]() |
![]() |
![]() |
#1103 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
EDIT: or are you asking if you can get the actual clipboard contents? Yes. This line in the template does that. Code:
text = str(QApplication.clipboard().text()).strip() Code:
python: def evaluate(book, context): from qt.core import QApplication return str(QApplication.clipboard().text()).strip() Last edited by chaley; 05-11-2023 at 11:02 AM. |
|
![]() |
![]() |
![]() |
#1104 |
Enthusiast
![]() Posts: 30
Karma: 10
Join Date: Oct 2012
Device: kobo libra 2
|
Hi, is there a way to use a chain as an action in another chain?
I’m trying to use composition instead of having to rewrite every actions when creating specific chains. An example. I’m using custom column for the #type of ebook (book, manga… it can take more than one value, and an imported file is set to none), its #origin (bought, given), its #source (what store…), if I’ve #done cleaning it. I’ve got a chain "1" for setting the #type to "book" (removing "none" and adding "book"). A chain "2" to set to a specific bookstore: set #origin to "bought" and #source to "7switch". A chain "3" to set #done to true. When working on a batch of books (for example re-importing all my bought books from the 7switch store), I would like to create a chain "4" that is just a composition of "1", then "2", then "3". Is there already a way to do that that I’ve missed? Thanks a lot for all the work. |
![]() |
![]() |
![]() |
#1105 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Calibre Preferences > Tweaks > Plugin Tweaks. Add action_chains_experimental = True
This will enable a 'Chain Caller' action which lets you run another chain. It's a little slow as there's checks for recursion to prevent it getting stuck in an endless loop. Note: While doesn't seem to be the case here, this may be useful later on: if the reason for using chain-caller is to avoid duplication of templates used for Single-Field Edits, you can use a stored template (Calibre Preferences > Template Functions > Stored Template tab). As it skips the recursion check, using a stored template in the SFE is faster than using chain-caller on a single-action chain used to hold the template: Last edited by ownedbycats; 05-24-2023 at 02:20 PM. Reason: Add info on stored templates |
![]() |
![]() |
![]() |
#1106 |
Enthusiast
![]() Posts: 30
Karma: 10
Join Date: Oct 2012
Device: kobo libra 2
|
Thanks, that’s exactly what I was looking for.
The slowness of the recursion checking is not a problem for me, but it’s nice to know there is a workaround if needed. While doing some tests, I’ve noticed the chains are identified by there title, so changing it is removing its shorcut association, or breaking the Chain caller action. Not a problem for me because I won’t be renaming chains now. Have a good day everyone. |
![]() |
![]() |
![]() |
#1107 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
The recursion check does not cause any delay at all. It does not even take 0.01 of a second. This is simply a wrong impression.
|
![]() |
![]() |
![]() |
#1108 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
SFE: On taglikes, does 'predefined value' overwrite column contents, or adds it as a new entry?
|
![]() |
![]() |
![]() |
#1109 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
|
AttributeError using 1.18.7 in Calibre 6.19.1, action type "Calibre Actions"
Using version 1.18.7 I get an error when I try to add or modify an action type "Calibre Actions" and try calling its settings:
Code:
calibre, version 6.19.1 ERROR: Unhandled exception: <b>AttributeError</b>:'int' object has no attribute 'replace' calibre 6.19.1 embedded-python: True Linux-6.3.3-200.fc38.x86_64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF') ('Linux', '6.3.3-200.fc38.x86_64', '#1 SMP PREEMPT_DYNAMIC Wed May 17 14:31:24 UTC 2023') Python 3.10.1 Interface language: en_GB Successfully initialized third party plugins: [...] Traceback (most recent call last): File "calibre_plugins.action_chains.gui.__init__", line 46, in setup_ui self.widget = self.widget_cls(self.plugin_action, self.chain_name, self.chains_config) TypeError: CalibreActionsWidget.__init__() takes 2 positional arguments but 4 were given During handling of the above exception, another exception occurred: Traceback (most recent call last): File "calibre_plugins.action_chains.gui.views", line 430, in _on_button_clicked d = SettingsWidgetDialog(name, self, self.plugin_action, config_widget, action, m.chain_name, m.chains_config, title) File "calibre_plugins.action_chains.gui.__init__", line 41, in __init__ Dialog.__init__(self, title, name, parent) File "calibre/gui2/widgets2.py", line 225, in __init__ File "calibre_plugins.action_chains.gui.__init__", line 51, in setup_ui self.widget = self.widget_cls(self.plugin_action) File "calibre_plugins.action_chains.actions.calibre_actions", line 162, in __init__ self._init_controls() File "calibre_plugins.action_chains.actions.calibre_actions", line 197, in _init_controls self._populate_actions_tree(lookup_menu_map) File "calibre_plugins.action_chains.actions.calibre_actions", line 287, in _populate_actions_tree self._populate_action_children(QMenu.actions(m), tl, File "calibre_plugins.action_chains.actions.calibre_actions", line 307, in _populate_action_children text = get_title(ac, plugin_name) File "calibre_plugins.action_chains.actions.calibre_actions", line 74, in get_title safe_title = get_safe_title(action) File "calibre_plugins.action_chains.actions.calibre_actions", line 68, in get_safe_title return text.replace('&&', '—').replace('&', '').replace('—', '&') AttributeError: 'int' object has no attribute 'replace' |
![]() |
![]() |
![]() |
#1110 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Editor Plugin] Editor Chains | capink | Plugins | 106 | 06-17-2025 05:36 PM |
Action Chains Resources | capink | Plugins | 77 | 06-16-2025 12:45 PM |
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB | lrpirlet | Plugins | 2 | 08-18-2022 03:15 PM |
[GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 14 | 04-04-2021 05:25 AM |