01-17-2023, 05:20 PM | #481 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
In this specific case, the switch_if() is in #kobopath, which is called by the save template ({#kobopath:re(_,/)}/{author_sort:sublist(0,1,&)}/{title} - {authors}).
Just to be safe, I set up this template rule, so I tend to know right away that I loaded up the wrong version. |
01-21-2023, 08:17 PM | #482 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
New question:
I have a composite colum, #chapters, which formats the chapter count: Code:
program: input = $#kobobookmark; # Don't change this to 'count' as that's a function ccount = $$#chaptercount; if ## Checks that a Fanfiction has a Kobo bookmark of the right format and is not anthology|oneshot $#booktype=='Fanfiction' && substr(input, 0, 10) == 'OEBPS/file' ## I'm not sure why this line is backwards && $#fanficstatus in 'Anthology,Oneshot' then ## Extracts number from bookmark, subtracts 1, and then formats them as 'currentchap/totalchap' strcat(format_number(re(input, '.*\/file(\d+).*', '\1') - 1, '{0:,d}'), '/',ccount) ## Display 'Not Set' if there's no chapter count elif ccount == 'None' then 'Not Set' ## Display regular chapter count - ignore '1' on most books (magazines, reference books, etc) elif $#booktype=='Fanfiction' ||ccount >#1 then ccount fi I have a stored template, fanfic_unreadchaps(), that checks the composite column and subtracts the first number from the second. 10/20 produces '10' and 5/5 produces '0.' Code:
program: if '/' in $#chapters then f = re($#chapters, '(.*)/.*', '\1'); s = re($#chapters, '.*/(.*)', '\1'); (s - f) fi This is used in several places; saved searches, column colour/icon rules, action chains templates. Would performance improve much if I used something like this, that checked the relevant columns directly rather than the composite? Code:
program: input = $#kobobookmark; if $#booktype == 'Fanfiction' && substr(input, 0, 10) == 'OEBPS/file' && !$#fanficstatus in 'Anthology,Oneshot' then currentchap = re(input, '.*\/file(\d+).*', '\1') - 1; totalchap = $#chaptercount; totalchap - currentchap fi Last edited by ownedbycats; 01-21-2023 at 10:03 PM. |
Advert | |
|
01-21-2023, 09:22 PM | #483 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Additionally, something I forgot: logical-and is '&&.' What is a logical-or?
EDIT: Found it in the reference. || ANOTHER EDIT: In the Calibre search, it's possible to do something like this to find matches in both groups: (title:foo AND author:bar) OR (title:bar AND author:bar) if possible, how would the same thing be done in a template? Last edited by ownedbycats; 01-21-2023 at 10:06 PM. |
01-22-2023, 05:43 AM | #484 | |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
If the composite is used only once then the second approach is faster because the template isn't as complicated. However, the second approach introduces maintenance problems, as you would have two (or more) places that make assumptions about column contents. Of course, the fastest would be to use a Python template for #chapters. These are as fast as native calibre code. Note: the composite cache is cleared whenever metadata changes. If you are using these templates in action chains where the chains alter metadata then the cache won't be as effective. |
|
01-22-2023, 05:55 AM | #485 | |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
('foo' in $title && 'bar' in $author) || ('bar' in $title && 'bar' in $author) Code:
('foo' in $title || 'bar' in $title) && 'bar' in $author Code:
(title:foo OR title:bar) AND author:bar Code:
'foo|bar' in $title && 'bar' in $author Code:
title:~foo|bar AND author:bar |
|
Advert | |
|
01-22-2023, 01:42 PM | #486 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That works! I was able to combine two if-thens that returned the same value:
Code:
if select($identifiers, 'url') && !'Anthology' in $#fanficstatus then if $publisher == 'Archive of Our Own' && !select($identifiers, 'ao3') then 'metadata.png' elif $publisher == 'FanFiction.net' && !select($identifiers, 'ffnet') then 'metadata.png' fi fi, into this: Code:
if select($identifiers, 'url') && !'Anthology' in $#fanficstatus then if ($publisher == 'Archive of Our Own' && !select($identifiers, 'ao3')) || ($publisher == 'FanFiction.net' && !select($identifiers, 'ffnet')) then 'metadata.png' fi fi, |
01-22-2023, 03:30 PM | #487 | |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
01-24-2023, 02:57 AM | #488 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Question:
Previously, in the template I have to generate Kobo collections (not composite; Action Chains single-field edit) was something like this: Code:
if $#booktype == 'Fanfiction' then 'Fanfiction' fi, if $#booktype == 'Fiction' then 'Fiction' fi, if $#booktype == 'Nonfiction' then 'Nonfiction' fi, Obviously, that could be simplified: Code:
program: genre = $#subjects; colls = strcat( $#booktype, if 'overdrive' in approximate_formats() then 'Loans,' fi, if $$#purchasecost == '0.00' then 'Freebies,' fi, if '^Horses$' inlist genre then 'Horses,' fi, if '^Cozy Mystery$' inlist genre then 'Cozy Mysteries,' fi, if '^(Fantasy|Science Fiction|Paranormal)$' inlist genre then 'Fantasy & Sci-Fi,' fi, if 'Omnibus' in $#admintags then 'Omnibuses' fi ); new_colls = list_union($#kobocoll, colls, ',') Last edited by ownedbycats; 01-24-2023 at 03:01 AM. |
01-24-2023, 04:30 AM | #489 | |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: genre = $#subjects; colls = strcat( $#booktype, ',', [...] |
|
01-24-2023, 05:45 AM | #490 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
#kobocoll is a taglike column so I'd think it'd remove excess commas anyways. Thanks
|
02-03-2023, 12:43 PM | #491 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
New question:
I created several user-categories to group the entries in taglike #fanficcat. (For several reasons, I prefer to leave the column itself as nonhierarchical entries.) To find books that have entries not present in the categories, I search for #fanficcat:true AND @Fanfiction.Fandoms:.false. Is it possible to also check this with a template? EDIT: Code:
program: if $#fanficcat && !'Fandom' inlist user_categories() then 'aaaa' fi Last edited by ownedbycats; 02-05-2023 at 09:50 PM. |
02-05-2023, 05:00 PM | #492 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
In the book list, there's a stray comma at the beginning of this composite taglike. Where is it coming from?
EDIT: It goes away if I run the strcat through list_remove_duplicates. Last edited by ownedbycats; 02-05-2023 at 05:03 PM. |
02-05-2023, 07:13 PM | #493 |
Addict
Posts: 287
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
|
I'm not familiar with using @ in a search like that and can't find it in the user manual. How does that work?
|
02-05-2023, 07:24 PM | #494 |
Custom User Title
Posts: 8,624
Karma: 61176603
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
You need to set up a user category. In the tag browser click 'configure' and then 'manage authors, tags > user categories.'
|
02-05-2023, 07:58 PM | #495 |
Addict
Posts: 287
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
|
So it's effectively a prefix for user categories in the same way that # is a prefix for user columns?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 138 | 04-23-2024 11:49 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 |