View Single Post
Old 11-04-2012, 11:36 AM   #993
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: 6,329
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
Let's see if a brief review on how replace_metadata works will help.

replace_metadata lines can take one of three different forms.

The first and simplest is: pattern=>replacement

All metadata items that matches regexp 'pattern' will be replaced using the standard Python regexp library like so: "value = re.sub(pattern,replacement,value)"

So, for example, if you are offended by the word Furbie and never want to see it anywhere in your metadata, you do:
Code:
Furbie=>F*rbie
The second form is: metakey[,metakey]=>pattern=>replacement

The only difference is that you are limiting which metadata items the line will apply do by including one or more 'metakeys'.

Metakey is one of the metadata items defined by FFDL (category, genre, rating, etc) or added by extra_valid_entries.

So, for example, if you what Humor converted to Comedy in genre and category:
Code:
genre,category=>Humor=>Comedy
The third form is:
metakey[,metakey]=>pattern=>replacement&&conditionalkey=>condregex p

This essentially says, "For metadata items 'metakey', if metadata item 'conditionalkey' matches 'conditionalkey', replace 'pattern' with 'replacement'.

Now there are three conditions that must be true before the replacement is done. 1) It must be a metadata item 'metakey', 2) the value must match 'pattern' and 3) the value of metadata item 'conditionalkey' must match 'condregexp'.

Code:
 characters=>Sam W\.=>Sam Witwicky&&category=>Transformers
 characters=>Sam W\.=>Sam Winchester&&category=>Supernatural
Replacements are applied in order--so plan accordingly.

Another tip: If you want to be able to test your patterns without hitting your favorite stories again and again, you can use the fake test site and the extracharacters, extracategories, etc parameters. test1.com URLs will generate stories, but not go out to the network.

URL: http://test1.com?sid=12345

Code:
[test1.com]
extracharacters:Reginald Smythe-Smythe,Mokona,Harry P.

replace_metadata:
 characters=>Harry P\.=>Harry Potter
JimmXinu is offline