![]() |
#1456 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
After adding the tweak and restarting, do the following:
|
![]() |
![]() |
![]() |
#1457 |
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
|
Problem is, I don't get the entry for "Chain variations" (see attached pictures), although I've added the tweak,
|
![]() |
![]() |
![]() |
#1458 |
Connoisseur
![]() Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
|
You have to right clic
|
![]() |
![]() |
![]() |
#1459 |
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
|
|
![]() |
![]() |
![]() |
#1460 |
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
|
|
![]() |
![]() |
![]() |
#1461 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
|
![]() |
![]() |
![]() |
#1462 |
Connoisseur
![]() Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
|
Help
Hi, I don't know what to do with one of my chains. The end of the chain is supposed to count the ebook's pages using the 'Count Pages' plugin using the Goodreads metadata. Everything is fine. The problem is that sometimes Goodreads doesn't have the page count in its metadata, which leaves me with a blank space in the corresponding column.
I have to enter the value manually or press 'Estimate page/word count' in the 'Count Pages' plugin. I added it to the chain and added the condition that it would run if the column was empty, but it doesn't work. I don't know what to do. ![]() ![]() ![]() |
![]() |
![]() |
![]() |
#1463 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
I am not a user of the Count Page plugin, so I can't help much. But the common error people do, is that they assume that conditions check every book which is not the case. It only works on the single active book selection. And conditions are meant as a binary on/off switch on the action as the whole.
What you want to do here is, at the end of your chain, limit the selection using "Search Using Templates" action with the following template: Code:
program:
book_ids = '';
for book_id in from_selection('id'):
if book_field(book_id, '#page_count') == '' then
book_ids = list_union(book_ids, book_id, ',')
fi
rof
After that apply the Count Pages plugin on the newly selected books. Edit: To solve the solution in an easier way without needing to write templates, I am considering adding a new action called 'Restrict current selection', which will narrow down the selected books using a regular calibre search e.g. #page_count:false. Or maybe amend Selection Modifier to add this feature. This can already be done using scopes, but "Calibre Actions" does not support scopes and relies instead on the "Selection Modifier" Last edited by capink; 03-23-2025 at 10:32 PM. |
![]() |
![]() |
![]() |
#1464 | |
Connoisseur
![]() Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
|
Quote:
Code:
program: if 'goodreads:' inlist $identifiers && $#book_pages == '' then 'yes' else 'x' fi ![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
#1465 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
I have my own primitive "Count Pages" chain, that uses a python action to count pages based on the number of characters in a book. Here is the python action if you are interested: Code:
import os import traceback from calibre.ebooks.oeb.polish.container import get_container from calibre_plugins.editor_chains.etree import get_text, etree chars_per_page = 2100 col = '#pages' book_format = 'epub' def create_container(book_path): if not book_path: raise FileNotFoundError if not os.access(book_path, os.W_OK): raise PermissionError container = get_container(book_path) return container def run(gui, settings, chain): db = gui.current_db book_ids = chain.scope().get_book_ids() book_id_page_map = {} for book_id in book_ids: book_title = db.title(book_id, index_is_id=True) print(f'Processing book: {book_title}') try: fmts_string = db.formats(book_id, index_is_id=True) if fmts_string: available_fmts = [ fmt.strip() for fmt in fmts_string.split(',') ] if book_format.upper() in available_fmts and ( book_format.upper() in ['EPUB', 'AZW3'] ): book_path = db.format_abspath(book_id, book_format, index_is_id=True) container = create_container(book_path) spine_names = [name for name, is_linear in container.spine_names] ch_count = 0 for name in spine_names: root = container.parsed(name) #text = get_text(root) text = etree.tostring(root, encoding='unicode', method='text') ch_count += len(text) book_id_page_map[book_id] = ch_count / chars_per_page print(' Done.') else: print(f' Format ({book_format}) not found for book.') except: print(f'FAILURE: {book_title} ({book_id})') traceback.print_exc() db.new_api.set_field(col, book_id_page_map) Last edited by capink; 03-23-2025 at 11:09 PM. |
|
![]() |
![]() |
![]() |
#1466 |
Member
![]() Posts: 11
Karma: 10
Join Date: Nov 2023
Device: none
|
Thanks and a Question about Metadata download
Thanks for your help last time! I made now some Phyton scripts that help with my condition problem that I had before! I use them together with integrated options like search and replace.
It saved me a lot of manual work ![]() --- I wanted to download specific Metadata from one site. I found a script in the Action Chain Resource Thread. (https://www.mobileread.com/forums/sh...9&postcount=28) But I do not understand how to use it. If I try to use it in a Chain it tells me "run" is missing. It would be nice if you have some advice how that script is meant to be used. |
![]() |
![]() |
![]() |
#1467 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Chain: Add Purchase Information, has single-field edit for #purchasesource (enum) and also other fields.
Other chain sets #purchasesource to specific value then calls the Add Purchase Information. Can skip the redundant SFE with condition? Last edited by ownedbycats; 04-03-2025 at 05:31 PM. |
![]() |
![]() |
![]() |
#1468 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
Code:
program: if globals(_caller) inlist 'my first chain,my second chain, ....' then 'skip' fi comparison operator > != Condition value > skip You can also use a condition to check the value of the said field, presuming the default value in nil. Last edited by capink; 04-04-2025 at 07:28 PM. |
|
![]() |
![]() |
![]() |
#1469 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Quote:
|
|
![]() |
![]() |
![]() |
#1470 | |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Quote:
What would I use specifically for the first one? I wasn't sure if it'd be if globals(_caller) inlist 'Cleanup: Kobo, Add Purchase Information' or something else. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |