|
|
#1576 | |
|
Leftutti
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 624
Karma: 3671119
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
|
Quote:
![]() Code:
from calibre_plugins.action_chains.actions.base import ChainAction
from calibre.utils.titlecase import titlecase
class MyAction(ChainAction):
# replace with the name of your action
name = 'Title Case Original Title'
support_scopes = True
def run(self, gui, settings, chain):
api = gui.current_db.new_api
selected_books = chain.scope().get_book_ids()
old_titles = api.all_field_for("#original_title", selected_books, None)
new_titles = {k: titlecase(v) for k, v in old_titles.items()}
updates = {k: v for k, v in new_titles.items() if v != old_titles[k]}
changed_ids = api.set_field(f"#original_title", updates)
# updating marks and view might be useful too?
#marks = {id: "Changed title" for id in changed_ids}
#gui.current_db.set_marked_ids(marks)
#gui.library_view.model().refresh_ids(changed_ids)
Code:
from calibre_plugins.action_chains.actions.base import ChainAction
from calibre.utils.titlecase import titlecase
class MyAction(ChainAction):
name = 'Mark Non-Titlecase Original Titles'
support_scopes = False
def run(self, gui, settings, chain):
api = gui.current_db.new_api
db = gui.current_db
all_books = list(api.all_book_ids())
titles = api.all_field_for("#original_title", all_books, None)
marks = {book_id: "caps_title" for book_id, title in titles.items() if title and title != titlecase(title)}
db.set_marked_ids(marks)
gui.library_view.model().refresh_ids(list(marks.keys()))
|
|
|
|
|
|
|
#1577 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 107
Karma: 1835990
Join Date: Nov 2010
Location: West of the Pecos
Device: FireHD8, iPad
|
Wondering if Actions Chains would do the following:
I routinely eMail ePubs to my Amazon Kindle account from within Calibre. This normally works perfectly as long as I verify that the ePub isn't too large (in MB). Usually I lossy compress the images to 40% or so and this takes care of any MB issue. So I eMail the ePub from within Calibre. I then check the "Jobs" to verify success. Finally, if successful, I have a custom column I've named "Sent" which I click upon and set the value to Yes which yields a green checkmark. A book I haven't yet sent displays a red "X". So can I craft some sort of Action Chain that does this: 1. eMail the book. 2. Verify the Job completed successfully. (If not, show a modal "failure" dialog.) 3. if the Job completed successfully, set the "Sent" column to "Yes". I seem to recall I asked a similar question some years ago and process #2 couldn't be done so process #3, therefore, wasn't done regardless of the success or failure of #2. I hope I've been clear enough. Thanks in advance for any assistance. Barry |
|
|
|
| Advert | |
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Action Chains Resources | capink | Plugins | 83 | 05-07-2026 02:16 AM |
| [Editor Plugin] Editor Chains | capink | Plugins | 131 | 04-26-2026 05:33 AM |
| [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 |