![]() |
#421 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
It is safe to modify the chain, but the chain will not run unless that action is available.
If you have a scenario in which you want to run the chain without the device plugged in; you have to set a connected_device_name() condition on that particular action, and also tick the option in the conditions evaluator to not validate the action if the conditions are not met. |
![]() |
![]() |
![]() |
#422 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I use connected_device_name for one of my chains. If the device is connected, it sends to device; if not it adds it to my "send to device" reading list to run when the device gets connected.
I just wanted to make sure it wouldnt remove 'invalid' actions when i saved it. ![]() Last edited by ownedbycats; 03-23-2021 at 09:34 PM. |
![]() |
![]() |
![]() |
#423 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@capink: Random thought -- does it make sense to give Single Field Edit the option to run over something other than the selection? I was thinking three options:
What do you think? |
![]() |
![]() |
![]() |
#424 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Running over non selected books is something I always pondered, not just for Single Field Edit, but for all builtin actions with the exception of calibre actions, which have to be always selection based, since the actions are not under the plugin control.
The way I imagined it was a template based solution, where the template returns list of ids. For example, to run over all ids the template below can be used: Code:
program: from_search('id', '') The stumbling block was whether to implement this for each action separately, or can there be a better way to implement a general mechanism used by all actions. Any suggestions would be welcome. This might take some time until I reach a solution I am comfortable with. Until then we can experiment with custom actions. To that end, I will introduce a change in the next version which will add a new action method — maybe call it loop_ids() — which can be overridden by subclasses to return the ids that will be acted on by the action. Edit: One concern with this approach will be how handle invalid template output as they will be difficult to validate ahead of time. Last edited by capink; 03-24-2021 at 03:43 PM. |
![]() |
![]() |
![]() |
#425 | |||||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Quote:
That said, a chain_vars-like action that returns a list of books is probably the best solution. That gets us back to the above questions... Quote:
You (we) also need to ensure that the complexity doesn't rise beyond the "usable point". That is a problem I have had with the template language for the last 10 years. Quote:
|
|||||
![]() |
![]() |
![]() |
#426 | |||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
Code:
from calibre_plugins.action_chains.actions.base import ChainAction class MyTestAction(ChainAction): name = 'My Test Action' def run(self, gui, settings, chain): book_ids = chain.chain_vars['book_ids'] book_ids = book_ids.split(',') book_ids = [int(book_id) for book_id in book_ids] print(book_ids) Quote:
Quote:
Edit: modify custom action make it convert book_ids to integer values. Last edited by capink; 03-24-2021 at 05:31 PM. |
|||
![]() |
![]() |
![]() |
#427 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
In general (not just for template issues) I think it would be a good idea to prompt "this action failed, continue rest of chain?" Some chains depend on specific action (or a series of actions) working correctly while others don't.
|
![]() |
![]() |
![]() |
#428 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Perhaps I should offer an error mechanism in the template language so that the template itself can indicate that something went wrong. Something like error('message') that throws a python ValueError. |
|
![]() |
![]() |
![]() |
#429 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Yes that really only applies if theres an error.
|
![]() |
![]() |
![]() |
#430 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Event: Book List Double Clicked
The plugin offers a builtin event called "Book List Double Clicked". Using this event, you can either replace calibre default action when double clicking on books with your own chain(s), or you can use your chain(s) to supplement calibre default action. If you want to completely replace calibre's default action with your chain(s), you have to edit the following tweak first to disable the default calibre action when double clicking (calibre preferences > tweaks):
Code:
doubleclick_on_library_view = 'do_nothing' However, editing the above tweak has the side effect of disabling editing a field using a single click. If you want to keep the ability to edit a field using single click after adding the above tweak, actions chains gives you this option, by adding another tweak (calibre preferences > tweaks > plugin tweaks): Code:
action_chains_single_click_edit = True Quote:
Last edited by capink; 08-19-2024 at 04:05 AM. |
|
![]() |
![]() |
![]() |
#431 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Version 1.5.0
The biggest change for this version is that Calibre Actions is now able use actions like Add books, convert books ... etc. The reason they were not included is outlined in the quote below: Quote:
However, there is only one remaining limitation; as the detection of a progress bar fails whenever the user check the "Hide Main Window" from the tray icon. So avoid using these together. The new double click event can be used to launch chain(s) in response to double clicking items on the library view. It might be better to disable the default action associated with double clicking if you want to use this event. (preferences > tweaks > doubleclick_on_library_view > do_nothing) Also I am not sure if the functionality of to_timestamp() is already present in calibre's template language. I checked format_date() and it does not seem to offer this possibility. If this is not the case, or if you think such functionality fits better into calibre template language, I will remove this function from future versions. Last edited by capink; 04-03-2021 at 06:18 AM. |
|
![]() |
![]() |
![]() |
#432 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
![]() Quote:
However, I think a good solution is to add the 'timestamp' format to format_date, returning a floating point timestamp. I would also change format_date() to allow a timestamp as the first argument (the "date") permitting conversion of timestamps to date strings. This would do what you need and also facilitate arithmetic on dates. Example: Code:
program: t = format_date($last_modified, 'timestamp'); strcat(t, ' -- ', format_date(t, 'yyyy MMM ddd hh:MM:ss')) Result: 1616695611.0 -- 2021 Mar Thu 18:03:51 |
||
![]() |
![]() |
![]() |
#433 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Example: Code:
program: t = format_date(today(), 'to_number'); format_date(t, 'from_number:MMM dd yyyy') Result: Mar 25 2021 Last edited by chaley; 03-25-2021 at 04:27 PM. |
|
![]() |
![]() |
![]() |
#434 | |||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
Quote:
![]() Quote:
|
|||
![]() |
![]() |
![]() |
#435 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,636
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
Thank you ,I think these options can simplify my process. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |