Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 05-15-2021, 01:40 PM   #106
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I fixed my saved search & replace!
ownedbycats is offline   Reply With Quote
Old 06-21-2021, 02:44 PM   #107
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
s = $#kobostatus;
c = $#kobocoll;

first_non_empty
   (
    contains(s, "Send to Device", 'sync.png', ''),
    contains(s, "Kobo Store", 'drm-locked.png', ''),
    contains(s, "On Loan", 'overdrive.png', ''),
    contains(c, "[Want to Buy]", 'cart_full.png',''),
    contains(s, "Sideloaded", 'reader.png',''),
   )
Why does this return cart_full.png when [Want to Buy] isn't present in #kobocoll?

Last edited by ownedbycats; 06-21-2021 at 03:09 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 06-21-2021, 03:32 PM   #108
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: 11,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
s = $#kobostatus;
c = $#kobocoll;

first_non_empty
   (
    contains(s, "Send to Device", 'sync.png', ''),
    contains(s, "Kobo Store", 'drm-locked.png', ''),
    contains(s, "On Loan", 'overdrive.png', ''),
    contains(c, "[Want to Buy]", 'cart_full.png',''),
    contains(s, "Sideloaded", 'reader.png',''),
   )
Why does this return cart_full.png when [Want to Buy] isn't present in #kobocoll?
Because the string is a regular expression. The brackets make it a character class, matching any character.

Last edited by chaley; 06-21-2021 at 05:10 PM. Reason: Spelling
chaley is offline   Reply With Quote
Old 06-21-2021, 03:49 PM   #109
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Oh, that makes sense. I removed the brackets and it worked and still matched.
ownedbycats is offline   Reply With Quote
Old 06-29-2021, 12:48 PM   #110
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Due to that composite column recursion glitch, I did this to avoid using variables in the template:

Code:
program:
	if 
			$#fanficcat 
		&& 
			$#currentlyreading 
		&& 
			$#kobobookmark
	then		
		 strcat(format_number(subtract((re($#kobobookmark, '.*\/file(\d+).*', '\1')), 1), '{0:,d}'), '/',$$#chaptercount)

	fi
Now that it's fixed in source, would changing them back to variables make the template run any more efficiently?
Code:
program:
input = $#kobobookmark;
a = re(input, '.*\/file(\d+).*', '\1');


	if 
			$#fanficcat 
		&& 
			$#currentlyreading 
		&& 
			$#kobobookmark
	then
		
		strcat(format_number(subtract(a, 1), '{0:,d}'), '/',$$#chaptercount)

	fi
Context: This template shows how many chapters of a fanfic I've read compared to how many exist. It checks that the book is a fanfic that's currently being read, then it extracts the number and since I pause at chapter beginnings it subtracts one:

Click image for larger version

Name:	2021-06-29 13_57_33-calibre — __ My Books __ Fanfiction __.png
Views:	147
Size:	10.1 KB
ID:	187933

ideally, it'd also check that $#kobobookmark starts with OEBPS/file but I've not quite figured out how to get it working yet.

Last edited by ownedbycats; 06-29-2021 at 01:01 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 06-29-2021, 01:28 PM   #111
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: 11,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Now that it's fixed in source, would changing them back to variables make the template run any more efficiently?
Yes, but probably not enough to notice. Turning something into a variable is good from an efficiency standpoint only if the variable is used more than once. In terms of speed improvement: on a reasonable computer, fetching a variable is sub-microsecond. Doing a field reference is probably about 10 times slower, but that isn't really slow in the grand scheme of things.
Quote:
ideally, it'd also check that $#kobobookmark starts with OEBPS/file but I've not quite figured out how to get it working yet.
Assuming 'a' is set and that it is not tags-like then something like
Code:
&& 
      substr(a, 0, 10) == 'OEBPS/file'
should work. You could probably get rid of the test for non-empty.
chaley is offline   Reply With Quote
Old 06-29-2021, 05:27 PM   #112
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I had to change a to input, but that worked in the template tester. Unfortunately I can't get Calibre to run from source anymore so I'm not sure if it actually works in the column itself.

EDIT: Until I fix the source issue (posted in development about it), I just subbed in my old code and put $#kobobookmark into the OEBPs test. That worked.

ANOTHER EDIT: Installing the Calibre beta lets me run from source again. it works. Actually since the beta also includes the recursion fix I can just use that.

Last edited by ownedbycats; 06-30-2021 at 12:43 AM.
ownedbycats is offline   Reply With Quote
Old 06-30-2021, 12:09 AM   #113
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
New question: Is count reserved and not for variables? It turned blue.

As a sidenote, I finally realized that if I use enter on the composite column and open the editor directly without going through the "add column" dialog I don't have to restart Calibre.

Last edited by ownedbycats; 06-30-2021 at 01:19 AM.
ownedbycats is offline   Reply With Quote
Old 06-30-2021, 04:34 AM   #114
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: 11,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
New question: Is count reserved and not for variables? It turned blue.
count is a built-in function which is why the template tester highlights it as it does. Using function names as variables works, but I really don't recommend it. I don't remember if there are places where the formatter checks whether it is a function when used in the context of a variable. I also can't guarantee that the behavior won't change.

Real reserved words such as 'if' and 'for' cannot ever be used as variables.
Quote:
As a sidenote, I finally realized that if I use enter on the composite column and open the editor directly without going through the "add column" dialog I don't have to restart Calibre.
I really never mentioned that? I implemented that years ago to avoid the restart. Do note that this "edit cell" method still changes last_modified for every book.

I use F2 because I use enter to edit metadata.
chaley is offline   Reply With Quote
Old 06-30-2021, 12:19 PM   #115
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I tried using it for a gpm template and got some unexpected outputs. So I changed it to ccount (for #chaptercount) instead.

I rarely pay attention to the last modified column anyways because it seems even sneezing causes it to change.

Last edited by ownedbycats; 06-30-2021 at 12:37 PM.
ownedbycats is offline   Reply With Quote
Old 06-30-2021, 09:55 PM   #116
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,906
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by chaley View Post
I really never mentioned that? I implemented that years ago to avoid the restart. Do note that this "edit cell" method still changes last_modified for every book.
Which is one of the reasons I always run from code. Fiddling with the columns in a database is not a reason to update the last modified timestamp of the records. I've spent to much time preventing that during far to many database migrations. Of course, it does depend on what the fiddling is, but, I definitely don't consider this to be valid reason.
davidfor is offline   Reply With Quote
Old 06-30-2021, 10:05 PM   #117
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,117
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
last_modified is for internal calibre use, its how calibre keeps track of whichbackup opf files need to be re-done. And editing column definitions definitely requiresthem to be re done. last_Modified, explicitly *does not* mean the last time the user edited the books metadata.
kovidgoyal is online now   Reply With Quote
Old 07-01-2021, 01:23 AM   #118
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,906
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by kovidgoyal View Post
last_modified is for internal calibre use, its how calibre keeps track of whichbackup opf files need to be re-done. And editing column definitions definitely requiresthem to be re done. last_Modified, explicitly *does not* mean the last time the user edited the books metadata.
I know we are not going to agree on this, but...

Unfortunately, most people do interpret last_Modified as when the metadata was last changed. They use it to decide things like if a book needs to be sent to their device or if they need to do some sort of work on the book.

But, I don't. I interpret it as when the last time something about that book changed. But, I completely disagree that changing the column definition is changing the book. Some changes yes, but, if I change the display format of a number to include a percent sign, I don't consider that is a change to the data, just how it will be shown in some place. Changing last_modified just seems wrong for this.

The same goes for changing a template or the list of values for a "Text, but with a fixed set of permitted values" (if I removed a value being used, that is different case). Adding or removing a column is a little different, but, I still would tend to not change the last_modified.

If the issue is to trigger the backup of the OPF files, then using "mark_as_dirty" with a parameter to not call "update_last_modified" should do it. The only thing missing is clearing some caches, but, as you need to reboot calibre after these changes, that will happen then. Of course, triggering that isn't hard to do.

And for the record, I had not realised that using "Queue all books for backup" would update last_modified. I suppose that demonstrates it is not a useful value for users and probably should not be displayed. And searching the code, I can't see anywhere that it is actually used. It gets set, but, I can't see anything that actually does something with it. From your comment, I was expecting to find tests using it.
davidfor is offline   Reply With Quote
Old 07-01-2021, 02:11 AM   #119
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: 8,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Are text and tag-likes formatted differently in the OPFs? that may make a difference.
ownedbycats is offline   Reply With Quote
Old 07-01-2021, 03:23 AM   #120
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,764
Karma: 27405072
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by chaley View Post
. . .

I use F2 because I use enter to edit metadata.
Curious: if you use enter to edit metadata (presumably in the booklist), what are you using F2 to do?

BR
BetterRed is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 153 05-14-2024 01:30 AM
[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 02:51 AM.


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