|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#1 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Feb 2022
Device: Kobo Libra 2
|
I need help with writing a template program to exclude some books from being tagged
I use the page count plugin plus a template program I adapted from one found online (included below) to build a column that categorizes books by length. (I use this to build collections I use when I’m picking my next to read)
I’d like to exclude certain books from getting a classification though if they are PDFs or have tags like “Graphic Novel” or “Cookbook”. I’d appreciate any help figuring this out. Thanks. Code:
program: val = field('#pagecount'); first_non_empty( cmp(val, 0, ' ', '', ''), cmp(val, 15, 'Flash Fiction', '', ''), cmp(val, 50, 'Short Story', '', ''), cmp(val, 100, 'Novelette', '', ''), cmp(val, 250, 'Novella', '', ''), cmp(val, 500, 'Short Novel', '', ''), cmp(val, 750, 'Long Novel', '', ''), cmp(val, 1000, 'Tome', '', ''), 'Toe Breaker'); Last edited by chaley; 01-07-2024 at 06:39 AM. Reason: Put template in code tags |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It isn't clear what you want to do.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Feb 2022
Device: Kobo Libra 2
|
Thank for replying. Sorry for not being super clear.
> Do you want to classify the book as above except if the book is PDF? Any other formats? I only have PDFs, epubs, and kepubs. The PDFs I have are only PDFs and contain no other formats. >What happens if a book has multiple formats? They will be included. Only PDFs will be excluded. >You don't want to classify if the book has one of a set of tags? Is that set subject to change? It shouldn’t ever change. I don’t use many tags in the tag browser. I only have a small number for things like graphic novels, cookbooks, or reference books. None of the books that I have specific tags for our books that one will ever just sit down and read, which is my goal and building this classification system. >What happens if a book isn't classified? I use these to build collections on my Kobo. In an ideal world, they just won’t be added to any collection. Based on the info from the Reddit page where I pulled the original program if I set the tag in that specific column to a single space, it should be ignored and that’s my ideal situation (https://www.reddit.com/r/Calibre/com..._pages_column/). >Does your classification template work (produce the wanted answer) for all books that should be classified? At this point yes the problem is it extra books that I don’t want to be lumped in with the others for example, graphic novels will have a page count but they aren’t really short stories or Novelettes. They are their own thing. |
![]() |
![]() |
![]() |
#4 | |||||
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Feb 2022
Device: Kobo Libra 2
|
Quote:
Quote:
Quote:
Quote:
Quote:
Thank you for your help. |
|||||
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I think this does what you want. You might need to add/change the tags in the list_intersection().
Code:
program: val = $#pagecount; if $formats && $formats != 'PDF' && list_intersection($tags, 'Graphic Novel, Cookbook', ',') == '' then switch_if( val ==# 0, '', val <# 15, 'Flash Fiction', val <# 50, 'Short Story', val <# 100, 'Novelette', val <# 250, 'Novella', val <# 500, 'Short Novel', val <# 750, 'Long Novel', val <# 1000, 'Tome', 'Toe Breaker') fi |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Feb 2022
Device: Kobo Libra 2
|
Thank you so much, that worked great.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to use re() function in Template Program Mode? | msciwoj | Library Management | 3 | 07-07-2016 03:55 PM |
Total size of tagged books | mkrubsack | Calibre | 7 | 03-14-2014 02:08 PM |
writing program help? | Anna Drake | Writers' Corner | 0 | 10-17-2013 04:38 PM |
General Program Template | StevieCoops | Library Management | 3 | 09-30-2013 11:02 PM |
Date formatting/template program mode | bookworm2000 | Library Management | 4 | 12-28-2012 04:41 PM |