View Single Post
Old 06-26-2013, 06:52 PM   #1506
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,039
Karma: 4604637
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by Jade Aislin View Post
Is there a way to add a character when the story does not have any?

When a story is downloaded, I want it to add 'no character' when there is no characters in the metadata. I'm primarily looking at FFN.
The fact that there are no characters isn't good enough to indicate 'no characters'??

This is what I've puzzled out that works:
Code:
# Add a new entry to hold the enhanced characters list.
extra_valid_entries:withnochars
withnochars_label:Characters

# Replace the regular characters list with withnochars in the title page.  
# It's your problem to do this everywhere you use characters. title, log, custom columns
titlepage_entries: seriesHTML,category,genre,language,withnochars,ships,status,datePublished,dateUpdated,dateCreated,rating,warnings,numChapters,numWords,site,description

# Add No Characters to characters always.
extracharacters:No Characters

# withnochars has all the real chars and No Characters
include_in_withnochars:characters

# Finally, remove No Characters from withnochars if there's 
# anything in characters other than No Characters.
replace_metadata:
 withnochars=>^No Characters$=>&&characters=>^(.+No Characters|No Characters.+)$
# The replacement is matching each list entry, while the conditional
# pattern (after &&) is matching the whole list with comma separators.
You can't match 'when it's empty' because when it's empty, replace_metadata isn't applied.

You can't do the replace directly on characters because that sets up an infinite recursion.

If you want this for a calibre column, I suggest you instead investigate creating a Custom 'Column built from other Columns' based on your (presumably) existing characters column. See attached and refer to the template manual.
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	194
Size:	48.9 KB
ID:	107377  
JimmXinu is offline