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 07-27-2024, 04:29 PM   #706
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 436
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
Quote:
Originally Posted by chaley View Post
In Template Program Mode spaces are significant outside the template code. You can't put a space between the colon and the quote.
Taking out the space didn't help. I'm still getting error.

Code:
{#koboreadpct:'cmp($,100,#read,#kobolastread,#read)'}
#koboreadpct is Integers
#read and #kobolastread are both Date

Any of them might be blank.

??

EDIT: The program version worked. I do wonder why the above doesn't.


Last edited by foosion; 07-27-2024 at 04:54 PM.
foosion is offline   Reply With Quote
Old 08-28-2024, 06:12 AM   #707
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: 9,532
Karma: 64960939
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
	status = readstatus();
	times = $$#timesread;
	readgoal = strcat('readinggoal:', format_date(today(), 'yyyy'));

	switch_if(
		status=='read', 'Read',
		status=='didnotfinish', 'Did Not Finish',
		status=='currentlyreading', 
			if times >#0 then 'Currently Rereading' 
			else 'Currently Reading' fi,
		status=='toberead', 'To Be Read',
		status=='unread', 
			if readgoal in $#admintags && $$#lastread then 'To Be Read' 
			elif readgoal in $#admintags then 'Backlog' 
			else 'Unread' fi,
		''
	)
Every book that matches unread and readgoal returns 'To Be Read', not just the ones with non-null dates. What did I do wrong?
ownedbycats is offline   Reply With Quote
Old 08-28-2024, 06:35 AM   #708
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,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Every book that matches unread and readgoal returns 'To Be Read', not just the ones with non-null dates. What did I do wrong?
A raw field reference returns the string None if the field is not defined. Use either
Code:
if readgoal in $#admintags && $$#lastread != 'None' then 'To Be Read'
or
Code:
if readgoal in $#admintags && raw_field('#lastread', '') then 'To Be Read'
chaley is offline   Reply With Quote
Old 08-28-2024, 07:03 AM   #709
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: 9,532
Karma: 64960939
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Yes, that works. Thank you.
ownedbycats is offline   Reply With Quote
Old 09-09-2024, 06:53 PM   #710
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: 9,532
Karma: 64960939
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I'd like to replace my 'Add Cleanup tag' and 'Remove Cleanup tag' action chains with a single one that toggles it.

Code:
program:

	if 
		'[Cleanup]' inlist $tags 
	then 
		list_difference($tags,'[Cleanup]' , ',') 
	else
		list_union($tags,'[Cleanup]' , ',')
	fi
Line 8 is failing - it works on its own, so the mistake is something with the conditions. What did I do wrong?
ownedbycats is offline   Reply With Quote
Old 09-09-2024, 07:06 PM   #711
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,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I'd like to replace my 'Add Cleanup tag' and 'Remove Cleanup tag' action chains with a single one that toggles it.

Code:
program:

	if 
		'[Cleanup]' inlist $tags 
	then 
		list_difference($tags,'[Cleanup]' , ',') 
	else
		list_union($tags,'[Cleanup]' , ',')
	fi
Line 8 is failing - it works on its own, so the mistake is something with the conditions. What did I do wrong?
The left side of the inlist operator is a regular expression. Brackets open a character class, so your 'if' is asking if any of the letters c, l, e, a, etc are in the tag. Use '\[Cleanup\]' to avoid the character class.

If the tag is actually the string '[Cleanup]', which your list_... expressions imply, then you can use the str_in_list() function to avoid regular expressions. Something like
Code:
program:

	if 
		str_in_list($tags, ',', '[Cleanup]', 1, '')
	then 
		list_difference($tags,'[Cleanup]' , ',') 
	else
		list_union($tags,'[Cleanup]' , ',')
	fi
This form is likely to be faster.
chaley is offline   Reply With Quote
Old 09-09-2024, 07:13 PM   #712
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: 9,532
Karma: 64960939
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Ah, I didn't realize it'd register as a regex - I use brackets to make it sort to the beginning. Thanks.
ownedbycats is offline   Reply With Quote
Old 09-16-2024, 04:34 AM   #713
JohnnyBook
Groupie
JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.JohnnyBook holds these truths to be self-evident.
 
Posts: 184
Karma: 126824
Join Date: Dec 2008
Location: Out There
Device: K3 W/3G (Fixed screen!) & Paperwhite Wifi
Currently the Series column shows digits.

Great Series [1]
Great Series [2]

Perfect.

But occasionally I want to break it down more and add decimals points with up to 2 digits.

Another Great Series [1]
Another Great Series [1.75] <-book/short story written later which fits here timewise.
Another Great Series [2]

Ok Good.

However usually I want to have 2 digits after the decimal point.

New Great Series [1.08] <- works great for monthly magazines i.e. 1979.08 for Aug '79
New Great Series [1.09]
New Great Series [1.10]
New Great Series [1.11]
New Great Series [1.12]

BUT The [1.10] gets displayed as [1.1] loosing zero in the 2nd decimal place, as is instead displayed like this:

New Great Series [1.08]
New Great Series [1.09]
New Great Series [1.1]
New Great Series [1.11]
New Great Series [1.12]

Is there a tweak I can use for the Series Column that will force it to use 2 decimal places if a decimal is used? (I do like it uses whole numbers if no decimal is involved. so [1] [2] are fine. I just want it to display [1.1] as [1.10])

Thanks,
JohnnyBook
JohnnyBook is offline   Reply With Quote
Old 09-16-2024, 06:20 AM   #714
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,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by JohnnyBook View Post
Is there a tweak I can use for the Series Column that will force it to use 2 decimal places if a decimal is used? (I do like it uses whole numbers if no decimal is involved. so [1] [2] are fine. I just want it to display [1.1] as [1.10])

Thanks,
JohnnyBook
No, there isn't. The solution is the one you got when you asked this question before, make a column built from other columns that displays the series as you like. Note that you can't edit such a column. Changes must be made in the series column.
chaley is offline   Reply With Quote
Old 09-20-2024, 08:44 PM   #715
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: 9,532
Karma: 64960939
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
On the inverse: How do I define a regex?

Since has_extra_files() is a bit slow, I'm adding the count to my admintags column with a template that:

1. Use a regex to match and remove any existing extra_files entries.
2. Generate a new extra_files entry.
3. Remove any entries matching 'extra_files:' exactly (zero files).

However, the regex on line 6 is failing to match:

Code:
program:

#to be replaced with $#admintags
tags = 'extra_files:123, blahblah';

old_tag = 'extra_files:\d+';
filecount = strcat('extra_files:', has_extra_files());

clean_tags = list_difference(tags, old_tag, ',');
new_tags = list_union(filecount, clean_tags, ',');

nonzero = list_difference(new_tags, 'extra_files:', ',')
I also tried strcat('extra_files:', '(\d+)');

Last edited by ownedbycats; 09-20-2024 at 08:47 PM.
ownedbycats is offline   Reply With Quote
Old 09-21-2024, 06:19 AM   #716
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,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
On the inverse: How do I define a regex?

Since has_extra_files() is a bit slow, I'm adding the count to my admintags column with a template that:

1. Use a regex to match and remove any existing extra_files entries.
2. Generate a new extra_files entry.
3. Remove any entries matching 'extra_files:' exactly (zero files).

[...]
Line 6 assigns a string to the variable old_tags. It doesn't care what the string is. It seems that you are expecting list_difference() to use the regular expression contained in old_tags to create a list. It doesn't do that. The parameters are lists, not expressions to create lists.

This does what I think you want:
Code:
program:

#to be replaced with $#admintags
tags = 'extra_files:123, blahblah';

# Remove any extra_files: items from the list
removed_ef = list_re_group(tags, ',', '.', '^extra_files:\d*$', '');
# Add the correct extra_files item to the list
added_ef = list_join(',', removed_ef, ',', 'extra_files:' & has_extra_files(), ',')
NB: you can use select() to get the value of the extra_files item, as in:
Code:
select(added_ef, 'extra_files')
It will return '' if there isn't an extra_files: item or if the item ends with a colon (no extra files).

NB2: I wonder if it is worth adding a list_filter() template function, as in
Code:
list_filter(list, sep, regexp)
It would remove any item matching the regexp from the list. The list_re_group() above does that, but using it in this way isn't particularly obvious.

The same question arises for adding list_add()
Code:
list = list_add(list, ',', string)
It would add one item to an existing list. Clearly you can do this with list_join() (as done above), but something like list_add() would make it more clear that a single item is being appended to the list. It would also be faster.
chaley is offline   Reply With Quote
Old 09-21-2024, 05:23 PM   #717
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,253
Karma: 6426810
Join Date: Sep 2020
Device: Calibre E-book viewer
Hi!

I got a chain that runs on event 'Book list Double Clicked". It works fine but I wonder if there's some hacky advancement that could accelerate it.

First action is open book.

Second action is a standard Single field edit that just sets a #lastread column date.

Third action is:
program:
$$#timesread + 1


Fourth action is:
program:
list_union(strcat(format_date($$#lastread, 'dd-MM-yyyy hh:mm:ss')), $#readdates, ',')


I remember I've asked chaley to convert some advanced emblem rules for cover grid to PTM instead of GPM. Would this be a case where such conversion can produce speed improvements?

Last edited by Comfy.n; 09-21-2024 at 05:53 PM.
Comfy.n is offline   Reply With Quote
Old 09-21-2024, 05:52 PM   #718
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,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
Hi!

I got a chain that runs on event 'Book list Double Clicked". It works fine but I wonder if there's some hacky advancement that could accelerate it.

First action is open book.

Second action is a standard Single field edit that just sets a #lastread column date.

Third action is:
program:
$$#timesread + 1


Fourth action is:
program:
list_union(strcat(format_date($$#lastread, 'dd-MM-yyyy hh:mm:ss')), $#readdates, ',')


I remember I've asked chaley to convert some advanced emblem rules for cover grid to PTM instead of GPM. Would this be a case where such a conversion can produce speed improvements?
If this is run on a single book when double-clicked then I wouldn't worry about performance. It only runs once per double-click. The template processing time will be swamped by the time required to open the book.

I assume that actions 3 and 4 are Single Field Edit where the result of the computation is stored in the appropriate cell for the current book -- the one double-clicked.
chaley is offline   Reply With Quote
Old 09-21-2024, 06:01 PM   #719
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,253
Karma: 6426810
Join Date: Sep 2020
Device: Calibre E-book viewer
thanks chaley

opening books is much faster now on latest preview, so the chain processing time has become more significant in relative terms
Comfy.n is offline   Reply With Quote
Old 09-21-2024, 06:05 PM   #720
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,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
thanks chaley

opening book is much faster now on latest preview, so the chain processing time has become more significant in relative terms
Those templates will run in under a millisecond, probably in 10s of microseconds. If you are seeing visible delays then they must be coming from action chains or locking inside calibre when opening the viewer.

You could try opening the book last instead of first, ensuring that calibre isn't busy doing something else when the actions update the database.
chaley 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 173 Yesterday 11:43 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 03:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 12:37 PM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 10:19 PM
Thread management questions meme Feedback 6 01-31-2011 06:07 PM


All times are GMT -4. The time now is 06:49 AM.


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