Mobileread
Plugboard, template, and custom composite column recipes
#1  chaley 10-02-2010, 07:13 AM
[Edited on 23/Jan/2011]

Several people are doing interesting and useful things with templates, plugboards, and composite fields. This thread is both a request that they share what they have done and a place to put the information.

Suggestions/recipes are summarized below. Don't hesitate to post corrections and useful variants.

Kindle/Kobo

Metadata: Show series - series Index - Title as Title (Kindle/Kobo) (economix)
Spoiler Warning below






I have been playing around with the Metadata plugboards to get the titles on a Kindle 3 to show series information. I used the following template:
format: mobi
device: kindle2
template: {series}{series_index:0>2s| - | - }{title}
destination: title

This works very nicely for books that are part of a series e.g.:
Quote
A Song of Ice & Fire - 01 - A Game of Thrones
A Song of Ice & Fire - 02 - A Clash of Kings
A Song of Ice & Fire - 03 - A Storm of Swords
A Song of Ice & Fire - 04 - A Feast for Crows

Metadata: Show series [series index] - title as title (Kindle) (Scott Nielsen)
Spoiler Warning below






format: mobi
device: kindle2
template: {series:|| }{series_index:0>2s|[|] - }{title}
destination: title

Metadata: Show author name as Initial and Surname (Kindle) (inspired by brewjono)
Spoiler Warning below






1) Verify author_sort values are Surname, Firstname order.
2) Uncheck 'use author sort' in the mobi output plugin.
3) Create a plugboard
format: mobi
device: kindle2
template: {author_sort:re(\, (.).*?( &|$),\, \1\2)}
destination: authors

Reading/read status custom column (Kindle) (pchrist7, w/ideas from beckywc):
Spoiler Warning below






Extract reading/read status from kindle annotations and show them in a custom column. See this post for details and instructions..


Filename (Save Templates)

Filename: author sort/series/title - version (WinCE/Mobile (Mobipocket))(sweetpea)
Spoiler Warning below






Using a version custom column in filenames
{author_sort}/{series}/{title} - v{#version:0>2s}

Filename: Create file paths grouping authors into [A - D]-like categories (WinCE/Mobile (Mobipocket)) (Sweetpea)
Spoiler Warning below






{author_sort:switch(^[A-D],[A - D],^[E-J],[E - J],^[K-O],[K - O],^[P-T],[P - T],^[U-Z],[U - Z],[Other])}

Filename: Create path based on series index (sweetpea, inspired by Arco Witter)
Spoiler Warning below






If you have a lot of books in a series, and want them in a folder hierarchy like series/00-09/author/title, series/10-19/author/title. You want just author/title if there is no series.
Create a composite column called (for example) #s_index.
Column: #s_dex
Template: {series_index:0>2s}

Save template:
Code
 {series}{#s_dex:switch(0.,00-09,1.,10-19,2.,20-29,3.,30-39,4.,40-49,5.,50-59,6.,60-69,7.,70-79,8.,80-89,9.,90-99,)|/|/}{author}/{title}


Sony Metadata

Metadata: Show author and title for title (Sony) (Sweetpea)
Spoiler Warning below






format: device-db
device: any device (or PRS505)
template: {authors} - {title}
destination: title

Metadata: Show title [series [series index]] as title, limiting series to 8 letters (Sony) (chaley)
Spoiler Warning below






Put 8 characters of the series plus the series index at the end of the title. The plugboard is:
[CODE]format: device-db
device: PRS505
template: {title}{series:<.8s| [|}{series_index:| [|]]}
destination: title

Metadata: Show series - series index - title, with series as initials (Sony) (inspired by speakingtohe)
Spoiler Warning below






The plugboard is:
format: device-db
device: PRS505
template: {series:re(([^\s])[^\s]+(\s|$),\1)}{series_index:0>2s| - | - }{title}
destination: title

Metadata: Given a yes/no 'Read' custom column, have the collections display Read, Reading, Unread (Sony) (sweetpea)
Spoiler Warning below






Assume that you have a custom yes/no column where you keep whether or not a book is read. Yes means the book is read, No means that the book is being read, and Unknown (empty) means that the book is to be read. This recipe will create a column containing Read/Reading/Unread that can be used to create a collection.

Create a composite custom column, named as you will. In this example we assume that the yes/no column is named #read. The new column's template will be:
template: {#read:switch(Yes,Read,No,Reading,Unread)}
Then put the new composite column's name into the fields to be used for series list in the Sony's device customization.


Apple iDevice Metadata

Metadata: Several examples (Apple devices) (GRiker)
See this post.

General Metadata

Metadata: Put series into the title, using either initials or a shortened form. Strip leading articles from the series name (any) (inspired by Gary_M_Mugford)
Spoiler Warning below






The solution requires creating three composite columns. The first column is used to remove the leading articles. The second is used to compute the 'shorten' form. The third is to compute the 'initials' form. Once you have these columns, the plugboard selects between them. You can hide any or all of the three columns on the library view.

First column:
Code
Name: #stripped_series. Template: {series:re(^(A|The|An)\s+,)||}
Second column (the shortened form):
Code
Name: #shortened. Template: {#stripped_series:shorten(4,-,4)}
Third column (the initials form) (Modified/corrected by eschwartz 6/Jan/14):
Code
Name: #initials. Template: {#stripped_series:re([\s]?([^\s])[^\s]+(\s|$),\1)}
Plugboard expression:
Code
Template:{#stripped_series:lookup(.\s,#initials,.,#shortened,series)}{series_index:0>2s| [|] }{title}
Destination field: title
This set of fields and plugboard produces:
Series: The Lord of the Rings
Series index: 2
Title: The Two Towers
Output: LotR [02] The Two Towers

Series: Dahak
Series index: 1
Title: Mutineers Moon
Output: Dahak [01] Mutineers Moon

Series: Berserkers
Series Index: 4
Title: Berserker Throne
Output: Bers-kers [04] Berserker Throne

Series: Meg Langslow Mysteries
Series Index: 3
Title: Revenge of the Wrought-Iron Flamingos
Output: MLM [03] Revenge of the Wrought-Iron Flamingos


Common composite custom columns

All the recipes below require the creation of a custom column of type 'Column built from other columns', called a composite column. Creation instructions are under the spoiler.
Spoiler Warning below






1. Go to preferences, Interface (the first row), Add your own columns.
2) Click the green plus sign.
3) Choose a lookup name. This will be the name you use for searching and in templates. It must be letters, all lowercase. Note that when you use the lookup name you must prefix it with a '#' character. Do not enter that character here.
4) Choose a column heading. This is what will appear at the top of the column.
5) Choose a column type. For the recipes below, that type must be 'Column built from other columns'.
6) Enter the template from the recipe into the template box.
7) Press OK, Apply, etc. Restart calibre.
Display the ISBN. Template: {isbn}

Display the formats for a book. Template: {formats}

Display Yes if the book has an EPUB format. Template:{formats:contains(EPUB, Yes,)}

Display the author sort. Template: {author_sort}

Display the title sort. Template: {title_sort}
Reply 

#2  economix 10-02-2010, 08:46 AM
Hi, thanks for implementing this feature.
I have been playing around with the Metadata plugboards to get the titles on a Kindle 3 to show series information. I used the following template:
Quote
{series} - {series_index:0>2s} - {title}
With title as the destination field. This works very nicely for books that are part of a series e.g.:
Quote
A Song of Ice & Fire - 01 - A Game of Thrones
A Song of Ice & Fire - 02 - A Clash of Kings
A Song of Ice & Fire - 03 - A Storm of Swords
A Song of Ice & Fire - 04 - A Feast for Crows
Is what shows up in the title field on the Kindle.
However, when a book is sent that is not part of a series, I get a leading - - in the title e.g.:
Quote
- - To Kill a Mockingbird
I am wondering if there is a way to eliminate the extraneous dashes at the start of the title when there is nothing in the series field. Or alternatively, an easy way to turn the plugboard on and off depending on whether the book being sent is part of a series or not.
Reply 

#3  chaley 10-02-2010, 08:51 AM
Quote economix
I am wondering if there is a way to eliminate the extraneous dashes at the start of the title when there is nothing in the series field. Or alternatively, an easy way to turn the plugboard on and off.
Use
Code
{series}{series_index:0>2s| - | - }{title}
The vertical bars separate the value from leading and trailing text that is added only if the value is not empty.

You might want to take a look at the (new) template tutorial in the manual. There are lots of fun toys.
Reply 

#4  Sweetpea 10-02-2010, 09:33 AM
Thanks to the plugboard and composite fields, I can now use Calibre for my WinCE/Mobile (Mobipocket) devices.

The filename is made up as;

{author_sort}/{series}/{title} - v{#version:0>2s}

{title} consists of series and index, because the Sony isn't supported by the plugboard. It's not a big deal, as you want the series info with the title anyway, otherwise, ordering by title simply doesn't make any sense.

My plugboard is more interresting:

{#author_title_sort}{#raw:test( - [raw],)} - {title}

is plugged into the title field for PRC and MOBI files.

{#author_title_sort} is a field that looks a bit like {author_sort}, except I don't want the entire first name. Especially on my PDA, where the screenwidth is not too wide, the full name would take too much room.

"Andersen, Hans Christian - Fairy Tales"
vs
"Andersen, H.C. - Fairy Tales"

The {#raw} means I've not checked the book yet and I won't have it in PDF format.

I am working on a save template for my BBMini: it uses these composite fields:

{#folder_name} is a composite field: {#folder_a_t:lookup(#folder_a_t,#u_z)}
{#folder_a_t} is a composite field: {#folder_a_j:lookup(#folder_a_j,#folder_k_t)}
{#folder_k_t} is a composite field: {#k_o:lookup(#k_o,#p_t)}
{#folder_a_j} is a composite field: {#a_e:lookup(#a_e,#f_j)}
{#u_z} is a composite field: {#first_letter:contains([U-Z],[U - Z],)}
{#p_t} is a composite field: {#first_letter:contains([P-T],[P - T],)}
{#k_o} is a compositie field: {#first_letter:contains([K-O],[K - O],)}
{#f_j} is a compositie field: {#first_letter:contains([F-J],[F - J],)}
{#a_e} is a compositie field: {#first_letter:contains([A-E],[A - E],)}
{#first_letter} is a compositie field: {author_sort:.1}

I tried to add them into one, but it gave me an error
Reply 

#5  speakingtohe 10-02-2010, 05:12 PM
Just curious

Why isn't the SOny supported by the plugboard?

Helen
Reply 

#6  Manichean 10-02-2010, 05:21 PM
Quote speakingtohe
Just curious

Why isn't the SOny supported by the plugboard?

Helen
I believe it is... there's a PRS505 device, and from what I could gather from the plugins list, all Sony devices are handled by the same plugin. So, if you use PRS505, it ought to work.
Reply 

#7  chaley 10-02-2010, 05:24 PM
Quote speakingtohe
Just curious

Why isn't the SOny supported by the plugboard?

Helen
It is, but not in the way that people might expect.

The plugboard supports changing the metadata for books *in the book*. Sony's don't use the metadata in the books, but instead use the information in the device's database (unless something goes wrong and the database is rebuilt). For lots of reasons, the information in the sony database is built using calibre's metadata, not the book's metadata, so changes made using the plugboard won't be used in the database.

I can change the sony driver to use the plugboard when writing to its database, but the changes are non-trivial. My concern is that any mistake will change existing collection data. My experience to date with that sort of mistake has not been at all pleasant.

Edit: The restriction has been removed. Sony DBs are now fully supported by the plugboard, using the special format 'device_db'.
Reply 

#8  CCLady 10-02-2010, 07:15 PM
Quote chaley
Use
Code
{series}{series_index:0>2s| - | - }{title}
The vertical bars separate the value from leading and trailing text that is added only if the value is not empty.

You might want to take a look at the (new) template tutorial in the manual. There are lots of fun toys.

This works perfectly on the K1 - not on the K3. Is there something else I need to do, or is this something that needs to be added in Calibre itself?
Reply 

#9  Scott Nielsen 10-02-2010, 10:44 PM
Quote economix
I am wondering if there is a way to eliminate the extraneous dashes at the start of the title when there is nothing in the series field. Or alternatively, an easy way to turn the plugboard on and off depending on whether the book being sent is part of a series or not.
I don't have a dash between series name and index but other than that, this should accomplish what you are looking for.

{series:|| }{series_index:0>2s|[|] - }{title}
Reply 

#10  brewjono 10-02-2010, 11:11 PM
Quote CCLady
This works perfectly on the K1 - not on the K3. Is there something else I need to do, or is this something that needs to be added in Calibre itself?
It worked for me on my K3.

I would like to use a combination though where I reduce the author to last name, initial and the series as above. I didn't understand the hash (#) used by the other poster though.

Brewjono
Reply 

  Next »  Last »  (1/84)
Today's Posts | Search this Thread | Login | Register