Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-14-2024, 12:49 AM   #1411
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by Bozana View Post
Thank you so very much Comfy! xoxoxo I did it! I will do a video on it for just search and replace with Action Chains! I'm so happy!
I'm glad you managed to get the hang of it
Comfy.n is offline   Reply With Quote
Old 01-12-2025, 03:57 AM   #1412
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
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
Comfy.n is offline   Reply With Quote
Old 01-14-2025, 02:03 PM   #1413
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
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(',')
Now, in the settings of the action make sure to do the following:
  • Tick the option "search result is book ids"
  • Tick the checkbox "Select books"

Last edited by capink; 01-14-2025 at 02:07 PM.
capink is offline   Reply With Quote
Old 01-14-2025, 06:53 PM   #1414
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by capink View Post
The event naturally fires every time book(s) are added and selects those books exclusively.
For some reason, in my case, it would select only one book. So, say I add 4 books at once. It would select the latest one, only. (Windows 10 22H2, Calibre 7.24)

Quote:
Originally Posted by capink View Post
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.
Really cool, this works exactly the way I wanted. Books added, before chain run:

Click image for larger version

Name:	1 chain.png
Views:	119
Size:	6.2 KB
ID:	213087

After chain run:

Click image for larger version

Name:	2 chain.png
Views:	119
Size:	6.8 KB
ID:	213088

Comfy.n is offline   Reply With Quote
Old 01-15-2025, 11:24 PM   #1415
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
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.
Comfy.n is offline   Reply With Quote
Old 01-17-2025, 03:18 AM   #1416
dewd
Connoisseur
dewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfoldeddewd reads XML... blindfolded
 
Posts: 52
Karma: 52704
Join Date: Nov 2017
Device: none
Quote:
Originally Posted by Comfy.n View Post
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.
I have Calibre add a specific tag to all newly-added books, then my "deal with the new stuff" action chain selects those books, does its thing, then removes the tag from them. Doesn't matter if they were added in the last ten minutes or a week ago, they all get processed.
dewd is offline   Reply With Quote
Old 01-17-2025, 03:39 AM   #1417
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
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
Comfy.n is offline   Reply With Quote
Old 01-21-2025, 02:58 PM   #1418
correoparaappzz
Connoisseur
correoparaappzz began at the beginning.
 
Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
Quote:
Originally Posted by capink View Post
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(',')
Now, in the settings of the action make sure to do the following:
  • Tick the option "search result is book ids"
  • Tick the checkbox "Select books"
and if i just want it to only show the recently added
correoparaappzz is offline   Reply With Quote
Old 01-21-2025, 03:03 PM   #1419
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,197
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by correoparaappzz View Post
and if i just want it to only show the recently added
Just stick to the event defaults, and don't add this action to your chain.
capink is offline   Reply With Quote
Old 01-25-2025, 09:01 PM   #1420
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
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?
ownedbycats is online now   Reply With Quote
Old 01-26-2025, 06:52 AM   #1421
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,197
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
How do I change a virtual library within a chain?
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?
capink is offline   Reply With Quote
Old 01-26-2025, 10:25 AM   #1422
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
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.
ownedbycats is online now   Reply With Quote
Old 01-31-2025, 11:00 AM   #1423
Nicolas.Laurent
Member
Nicolas.Laurent began at the beginning.
 
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).
Nicolas.Laurent is offline   Reply With Quote
Old 01-31-2025, 11:18 AM   #1424
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
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'})
To retrieve the variable using python:
Code:
chain.chain_vars.get('variable_name', '')
To retrieve the variable using calibre template language:
Code:
program:
    my_retrieved_variable = globals(variable_name)
If you want to set a chain variable without using python, you can use the Chain Variables action.
capink is offline   Reply With Quote
Old 01-31-2025, 12:12 PM   #1425
Nicolas.Laurent
Member
Nicolas.Laurent began at the beginning.
 
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?
Nicolas.Laurent is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 03:20 PM.


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