![]() |
#1411 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
|
|
![]() |
![]() |
![]() |
#1412 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
|
I'm testing a chain with Books Added event that does this:
1. Searches for date:today, then selects all books on current book list view; 2. Runs a Quality Check action twice to swap author name FN, LN (this achieves the result I want in author sort column, as I have the tweak 'Author sort name algorithm' set to author_sort_copy_method = 'copy'.) It runs fine, but I want to modify the search to select the items added in the last hour, or last 10 minutes, something like that. The event manager has a specific option to 'Select newly added books" automatically but it will only select the most recently added one. Any ideas welcome |
![]() |
![]() |
![]() |
#1413 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,197
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
The event naturally fires every time book(s) are added and selects those books exclusively. Does not make sense for it to select books that were added an hour ago, at which time the event fired for these books.
Seems like you want to do is more suited for a timer event that executes a chain periodically at a configurable time intervals. Whichever way you choose to go, here is a python template that should work with the "Search using template" action, it will select books added in the last hour, you can edit the code (the part highlighted in red), to your liking. Code:
python:
def evaluate(book, context):
from calibre.utils.date import now
book_ids = ''
db = context.db
current = now()
for book_id in db.data.search_getting_ids('date:today', ''):
dt = db.new_api.field_for('timestamp',book_id)
delta = current - dt
if delta.total_seconds() < 60 * 60:
book_ids += f'{book_id},'
return book_ids.strip(',')
Last edited by capink; 01-14-2025 at 02:07 PM. |
![]() |
![]() |
![]() |
#1414 | ||
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
|
Quote:
Quote:
After chain run: ![]() ![]() |
||
![]() |
![]() |
![]() |
#1415 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
|
Well, today the auto-select newly added books worked on a test I did without the search template action... so perhaps I had some program interfering the other day.
|
![]() |
![]() |
![]() |
#1416 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 52
Karma: 52704
Join Date: Nov 2017
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#1417 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
|
Yeah, the not auto selecting issue is resolved now for me now, thankfully. This was just about a picky tendency I have related to the author sort field but I may find other uses for this awesome feature
|
![]() |
![]() |
![]() |
#1418 | |
Connoisseur
![]() Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
|
Quote:
![]() ![]() |
|
![]() |
![]() |
![]() |
#1419 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,197
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
|
![]() |
![]() |
![]() |
#1420 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,024
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
How do I change a virtual library within a chain?
|
![]() |
![]() |
![]() |
#1421 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,197
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
What is it that you want to achieve by virtual library that cannot be done by clearing the existing virtual library and using a regular search in the Selection Modifier/Scope.
When writing the Selection Modifier, I was thinking about adding the ability to create virtual libraries but could see a scenario where a regular search won't suffice. Do you have any? |
![]() |
![]() |
![]() |
#1422 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,024
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Ah i didn't think of selection modifier.
|
![]() |
![]() |
![]() |
#1423 |
Member
![]() Posts: 22
Karma: 10
Join Date: Jun 2016
Location: France
Device: PocketBook Touch Lux 2
|
Hello everyone.
And sorry in advance for any linguistic errors, English is not my mother tongue. I'm looking to retrieve the value of a variable obtained using an input box. From the following code, in the 'Run Python Code' module, I manage to enter a value, but I don't know how to assign it to a variable for use in subsequent instructions. from PyQt5.QtWidgets import QInputDialog def run(gui, settings, chain): gui = chain.gui text, ok = QInputDialog.getText(gui, “Input”, “Enter your text:”) if ok and texte: my_input=text return True pass I've tried using the 'Chain Variable' module, but the code doesn't work. I'd be grateful for any help I can get in solving this problem for a new user of the Action Chains plugin (incredible, by the way). |
![]() |
![]() |
![]() |
#1424 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,197
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
To set a chain variable using python
Code:
chain.set_chain_vars({'variable_name': 'variable_value'}) Code:
chain.chain_vars.get('variable_name', '') Code:
program: my_retrieved_variable = globals(variable_name) |
![]() |
![]() |
![]() |
#1425 |
Member
![]() Posts: 22
Karma: 10
Join Date: Jun 2016
Location: France
Device: PocketBook Touch Lux 2
|
Many many thanks, it works perfectly!
I've probably missed something, is there any documentation on the syntax to use for Action Chains? |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |