Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-16-2014, 07:00 AM   #1
fxp33
Addict
fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 261
Karma: 110864
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD, kindle paperwhite
[solved] template: if one of the tag is sthg... maybe contains or in_list functions

Hi all,

Post Summary
Can someone provide a way to display a word in the filename depending on the presence of the tags? Something like :

If one of the tags is "xxx" then add "yyy" if not "zzz"

Detailed post

I am testing the way my books are rendered on my reader.
I need the template to add a special keyword in the filename (actually an extension prefix) when sending to device, depending on the tags I gave:

If one the tags is "kepub" display ".kepub" if not display ""

I didn't succeed with these syntaxes:
  • {tags:contains("kepub",".kepub","")}
  • {tags:in_list(",","kepub","kepub",".kepub")}
  • Notice that there is a syntax with 5 arguments (for the built-in templates) in the template engine. So I tried also: in_list({tags},",","kepub",".kepub","")

Can someone provide examples for those functions using the {tags} as value:
  • in_list(separator, pattern, found_val, not_found_val) Reference
  • contains(pattern, text if match, text if not match) Reference


Resources:
Thank you for your help,

Regards

François

Last edited by fxp33; 07-19-2014 at 05:20 AM. Reason: marked solved
fxp33 is offline   Reply With Quote
Old 07-16-2014, 08:46 AM   #2
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: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
The following seems to work:

Code:
{tags:'in_list($, ",", "kepub", ".kepub", "")'}
That will return ".kepub" if the tags contain "kepub". And nothing if it isn't

But, I have to ask, why? You can store kepubs in calibre. And if you send a book to a Kobo device using the KoboTouch driver, it can send either an epub or kepub. If you send a kepub, the driver names the file on the device as needed for it to be treated as a kepub. And if you have both formats for a book, you can set which the driver will send.

Last edited by davidfor; 07-16-2014 at 08:49 AM.
davidfor is offline   Reply With Quote
Advert
Old 07-16-2014, 08:59 AM   #3
fxp33
Addict
fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 261
Karma: 110864
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD, kindle paperwhite
Hi Davidfor,

As usual, your are a savior... A double savior :-)

I would never have guessed about the dollar argument in the function. Might be a good idea to insert a few examples in the manual. I will try to collect a few things and post them in the recipe.

For the driver use, i guess I didn't find the right way t send (without correcting) epub or kepub... I might look it up in the plugin forum.

Thank you again for your answer

François
fxp33 is offline   Reply With Quote
Old 07-16-2014, 09:50 AM   #4
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: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by fxp33 View Post
As usual, your are a savior... A double savior :-)

I would never have guessed about the dollar argument in the function. Might be a good idea to insert a few examples in the manual. I will try to collect a few things and post them in the recipe.
It was one of the things I missed early on and keep forgetting. The $ indicates where the value from the field goes. See http://manual.calibre-ebook.com/temp...e-program-mode for the explanation.
Quote:
For the driver use, i guess I didn't find the right way t send (without correcting) epub or kepub... I might look it up in the plugin forum.
The main thing is to have "kepub" selected in the list of formats for the driver. Otherwise calibre will attempt to convert the kepub to something else before sending.
davidfor is offline   Reply With Quote
Old 07-19-2014, 05:18 AM   #5
fxp33
Addict
fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 261
Karma: 110864
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD, kindle paperwhite
Hi, DavidFor,

Sorry for the delay, I was traveling for work.

Thank you very much for the details added in your explanation and for the link.

I might plunge into the manual this afternoon to understand fully how it works.

And for Calibre of course, this is a few hours more testing ahead

Regards

François
fxp33 is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting tag values in tag browser mcam Library Management 15 08-25-2013 05:50 AM
Send tag to device only if tag has more than 1 book? eosrose Calibre 0 01-29-2013 07:46 PM
Making references to other fields in template functions Ruskie_it Library Management 10 12-21-2011 10:53 PM
Does anyone use "general program mode" template functions? chaley Library Management 0 08-16-2011 11:54 AM
Adding an Owner tag to tag list? Fangles Library Management 1 02-25-2011 02:32 AM


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


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