Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 09-24-2021, 10:24 AM   #151
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kevn57 View Post
This is a repost as I posted in the wrong thread

I'm a complete nube in calibre template language.

I'm trying to take the output of the plugin Pagecount which is the number of words in a book and dividing that by 320 which is my words per minute reading rate and output the total number of minutes to read the book into my custom integer col "#minutes"

I don't know how to assign the product of divide(vals, 320); to my custom column #minutes.

program:
col = '#pagecount';
vals = from_selection(col);
'#minutes' = divide(vals, 320);

But I get this result EXCEPTION: Formatter: Expected end of program, found '=' near '#minutes' on line 4
Where do you want to use the template? I ask because you are using from_selection() that only works in action chains. If you want a composite column (built from other columns) with the lookup name '#minutes' then you would use this template for the column.
Code:
program:
    $$#pagecount / 320
If you don't want fractional minutes then use
Code:
program:
    floor($$#pagecount / 320)
or
Code:
program:
    round($$#pagecount / 320)

Last edited by chaley; 09-24-2021 at 11:09 AM. Reason: Grammar
chaley is offline   Reply With Quote
Old 09-24-2021, 11:05 AM   #152
kevn57
Connoisseur
kevn57 began at the beginning.
 
kevn57's Avatar
 
Posts: 93
Karma: 10
Join Date: Jun 2011
Location: Albany NY
Device: Moonreader+
capink, Thanks again for helping me out, I promise it won't be a daily occurrence.

Using your code a box popped up with the correct # of minutes, but I'd like to assign that number to my custom column #minutes is that possible?

Thanks Chaley
I went with round($$#pagecount / 320)

Last edited by kevn57; 09-24-2021 at 11:08 AM.
kevn57 is offline   Reply With Quote
Advert
Old 09-24-2021, 11:11 AM   #153
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kevn57 View Post
capink, Thanks again for helping me out, I promise it won't be a daily occurrence.

Using your code a box popped up with the correct # of minutes, but I'd like to assign that number to my custom column #minutes is that possible?

Thanks Chaley
I went with round($$#pagecount / 320)
I am confused by your replies to capink and me. Did you solve your problem? If not, what exactly did you try?
chaley is offline   Reply With Quote
Old 09-24-2021, 11:17 AM   #154
kevn57
Connoisseur
kevn57 began at the beginning.
 
kevn57's Avatar
 
Posts: 93
Karma: 10
Join Date: Jun 2011
Location: Albany NY
Device: Moonreader+
Sorry chaley, I have a custom column called Minutes, I'd like to assign the result of round($$#pagecount / 320) to that column.

In this particular case it 53062 / 320 the result of round($$#pagecount / 320) is 166.
Is there a way to put that number in my list view column #minutes. I can do it by hand but it'd be great to have it automatically inserted.
kevn57 is offline   Reply With Quote
Old 09-24-2021, 11:21 AM   #155
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,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
There's two ways to do this: a composite or using Action Chains to populate the column. The first one means it'll automatically update, but can't be manually tweaked (there's also performance to think about, but that's for stuff far more complex than this). The latter you'll need to run the chain if you want to update it but if you want to change it to something else you can.
ownedbycats is offline   Reply With Quote
Advert
Old 09-24-2021, 11:25 AM   #156
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
There's two ways to do this: a composite or using Action Chains to populate the column. The first one means it'll automatically update, but can't be manually tweaked. The latter you'll need to run the chain if you want to update it.
The first is done using a custom column of type "Column built from other columns" that uses a template to compute the column's value. The value is computed whenever the column is looked at, either by you or by calibre for some reason. As ownedbycats said, you can't change it except by changing the underlying data for that book, or by changing the computation (which changes all books). Note that you can't change the type of an existing column. You would need to create a new column and probably delete the existing one.

For the second you need to ask in the Action Chains plugin thread. What you do depends on how and when you want it updated.

Last edited by chaley; 09-24-2021 at 11:30 AM. Reason: More precision on changing a composite's value
chaley is offline   Reply With Quote
Old 09-24-2021, 11:40 AM   #157
kevn57
Connoisseur
kevn57 began at the beginning.
 
kevn57's Avatar
 
Posts: 93
Karma: 10
Join Date: Jun 2011
Location: Albany NY
Device: Moonreader+
Thank you all I went with Column built from other columns because I do not want the values to change I want it tied to Pagecount and it worked perfectly. Now I can see at a glance approximately how long it'll take to read the book
kevn57 is offline   Reply With Quote
Old 09-30-2021, 09:24 AM   #158
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,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Is there any sort of template function that returns the count of how many books are currently marked? For Action Chain conditions (run "clear all marked books" if there's only 1 marked book).
ownedbycats is offline   Reply With Quote
Old 09-30-2021, 09:37 AM   #159
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,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Try this:

Code:
program:
	marked = from_search('id', 'marked:true');
	count(marked, ',')
Edit: As rule, calibre templates only work per book (horizontally). If you want to get data that depends on more that one book, Action Chains functions (from_search & from_selection) should help by pulling data from multiple books (vertically).

Last edited by capink; 09-30-2021 at 09:58 AM.
capink is offline   Reply With Quote
Old 09-30-2021, 03:58 PM   #160
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,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
It works perfectly
Attached Files
File Type: zip TestClearMarks.zip (554 Bytes, 647 views)
ownedbycats is offline   Reply With Quote
Old 10-01-2021, 07:11 AM   #161
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,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question. Here's my "Update Kobo Path" template in my send-to-device chains:

Code:
program:

	if
		$#kobopath == ''
	then

# Returns 'Fanfiction.Fandom' for fanfics
		if $$#fanficcat then
			re(sublist($tags, 0, 1, ','), '\.', '/')

# Returns 'PDF' for PDFs
		elif $formats == 'PDF' then
			'PDF'

# Returns 'Loans' for Loans
		elif $#kobostatus == 'On Loan' then
			'Loans'

# Returns topmost tag for all other books
		else
			re(sublist($tags, 0, 1, ','), '^(.*?)($|\..*$)', '\1')
		fi
else
	$#kobopath
fi
I ran into a weird situation. I had a fanfiction with the @cleanup tag. I mistakenly ran send-to-device before removing the tag. #kobopath returned '@cleanup' instead of the expected Fanfiction.Fandom tag. What happened?

Last edited by ownedbycats; 10-01-2021 at 07:16 AM.
ownedbycats is offline   Reply With Quote
Old 10-01-2021, 07:23 AM   #162
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I ran into a weird situation. I had a fanfiction with the @cleanup tag. I mistakenly ran send-to-device before removing the tag. #kobopath returned '@cleanup' instead of the expected Fanfiction.Fandom tag. What happened?
The order of the tags is not guaranteed so you don't know the value of the first tag. In other words,
Code:
         sublist($tags, 0, 1, ',')
returns the first tag in the list, which could be any of the tags.

If order must be known then you need to sort the tags before the sublist. Or strip out the tags you don't want to return. Or do something else to get the tag you actually want.
chaley is offline   Reply With Quote
Old 10-01-2021, 07:52 AM   #163
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,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That makes sense. I think the easiest solution would to make it only run on tags starting with Fanfiction. (with the dot). Having a bit of trouble with the regex though.

Code:
program:

if $$#fanficcat then
			re(sublist($tags, 0, 1, ','), 'Fanfiction\.', 'Fanfiction/')

fi
didn't work (and it's a bit clumsy anyways)
ownedbycats is offline   Reply With Quote
Old 10-01-2021, 08:26 AM   #164
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
That makes sense. I think the easiest solution would to make it only run on tags starting with Fanfiction. (with the dot). Having a bit of trouble with the regex though.

Code:
program:

if $$#fanficcat then
			re(sublist($tags, 0, 1, ','), 'Fanfiction\.', 'Fanfiction/')

fi
didn't work (and it's a bit clumsy anyways)
What exactly are you trying to do? It looks like you want the word 'Fanfiction/' if the word 'Fanfiction.' is in tags. Right? If so then this works.
Code:
	if '^Fanfiction\.' inlist $tags then 'Fanfiction/' fi.
However, you might want 'Fanfiction.foo' to become 'Fanfiction/foo'. If so then this works:
Code:
	list_re($tags, ',', '^Fanfiction.(.*)$', 'Fanfiction/\1')
chaley is offline   Reply With Quote
Old 10-01-2021, 08:30 AM   #165
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,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Fanfiction.subtag-> Fanfiction/subtag is what I'm trying to do yes. I will try the second one
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 225 07-27-2025 02:07 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 02:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 11:37 AM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 09:19 PM
Thread management questions meme Feedback 6 01-31-2011 05:07 PM


All times are GMT -4. The time now is 01:19 AM.


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