![]() |
#1 |
Member
![]() Posts: 10
Karma: 10
Join Date: Nov 2015
Device: Sony PRS-T1
|
Save Books to Disk Template Problem
I have categories in my Author list i.e.
Tony Abbot & Colleen Madden (Illustration) Alexandre Dumas & Robin Buss (Translation) Is it is designed to do the Author_Sort ignores the entry in brackets. However, when I Save to Disk I would like the author as author_sort but including the element in brackets. I have looked through the manual and many entries in the Forum and haven't found an easy way of doing this. If I was using C or other programming language I would just split the author field into words and iterate through each entry. In Calibres template languages I don't know how to do this. I cannot just use author_sort and the last word in author if it is in brackets because there may be more than one author entry in brackets. If anyone has a way of doing this, or a better way of tracking Illustrators, Editors, Translators etc. I would like to hear from you. Thank you |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
You could use a custom column to store the illustrators and translators -- they are arguably not "authors".
Alternatively, you could manually set the author_sort, it is the automatic derivation of author_sort which doesn't include the parentheses content. Or use the list_re() function to apply a regex to each element in "authors", specifying & as the list separator. Personally I favor the custom column. ![]() Last edited by eschwartz; 11-15-2015 at 11:26 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,364
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Look at calibre's source code "calibre.db.cache" see what is in the mi structure. The built-in template function 'author_sorts' gets close to what you want and probably can be used as a starting point. Code:
def evaluate(self, formatter, kwargs, mi, locals, val_sep): sort_data = mi.author_sort_map if not sort_data: return '' names = [sort_data.get(n) for n in mi.authors if n.strip()] return val_sep.join(n for n in names) |
|
![]() |
![]() |
![]() |
#4 |
Member
![]() Posts: 10
Karma: 10
Join Date: Nov 2015
Device: Sony PRS-T1
|
eschwartz
Thank you for your suggestions. I have managed to extract the elements with brackets into a UDC but have so far not been able to work out a way of adding them to author_sort (list_union seems a possible method it I can get the bracketed items into a matching list) I prefer to limit the number of columns I use and I am not too precious about differentiating between the true author and others. To maintain a list of authors only would take more time than I am willing to invest because I have a lot of multi author magazines and anthologies. (: I use the Quality Check plug-in to ensure that my author_sort are up to scratch and manually editing author-sort would cause much confusion. chaley This looks like something I could work with so I am going to give it a go. Thank you to both of you. Are there any examples of complex templates (with explanation) ? (and UDF;s come to that) Regards |
![]() |
![]() |
![]() |
#5 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Sticky: Plugboard, template, and custom composite column recipes
Has a lot of custom templates designed for specific needs, and the first post collects a bunch of generic ones. UDFs are not quite as common, mostly because the template language is mostly all that people need. But you can do literally anything you want so long as it can be programmed in python based on the input of a metadata column. ![]() Last edited by eschwartz; 11-15-2015 at 11:28 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,364
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The source for every built-in template function is available at http://manual.calibre-ebook.com/gene...plate_ref.html. UDFs use the same structure.
You can find several examples of "real" UDFs by searching for "def evaluate" (with the quotes) with MobileRead's advance search. Be sure to change the result from "threads" to "posts". |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Preferences-Save to Disk Template | phossler | Calibre | 5 | 01-17-2014 06:43 PM |
Please help on a Save to Disk template | Dammie | Library Management | 15 | 12-16-2013 09:51 AM |
Need help on a Save to Disk template | fidvo | Library Management | 2 | 08-12-2012 03:34 PM |
Save to disk template help plz. | Crusher | Conversion | 12 | 03-15-2012 03:14 PM |
save to disk template | speakingtohe | Calibre | 9 | 05-29-2010 06:02 AM |