Add automatic adding of unrecognized metadata in base_efiction. For tgstorytime.com.

This commit is contained in:
Jim Miller 2016-02-06 13:22:51 -06:00
parent a644beea94
commit 7a08e3afdd
3 changed files with 43 additions and 1 deletions

View file

@ -1557,6 +1557,24 @@ extracategories:Transgender
## confirm they are adult for adult content.
#is_adult:true
## This site has a number of additional site specific metadata
## entries. This is the first test case of base_efiction 'Auto
## metadata' automatically including unrecognized metadata. Still
## requires entries in extra_valid_entries to be used.
extra_valid_entries:turnedinto,featureditems,locale,motivationforchange,sexualorientation,storytheme,bodymodification,personality,storytype,typeofchange
#add_to_titlepage_entries:,turnedinto,featureditems,locale,motivationforchange,sexualorientation,storytheme,bodymodification,personality,storytype,typeofchange
turnedinto_label:Turned Into
featureditems_label:Featured Items
locale_label:Locale
motivationforchange_label:Motivation for Change
sexualorientation_label:Sexual Orientation
storytheme_label:Story Theme
bodymodification_label:Body Modification
personality_label:Personality
storytype_label:Story Type
typeofchange_label:Type of Change
[thehexfiles.net]
## Site dedicated to these categories/characters/ships
extracategories:Harry Potter

View file

@ -314,7 +314,13 @@ class BaseEfictionAdapter(BaseSiteAdapter):
## TODO is not a link in the printable view, so no seriesURL possible
self.story.setMetadata('series', value)
else:
logger.info("Unhandled metadata pair: '%s' : '%s'" % (key, value))
# Any other metadata found, convert label to lower case
# w/o spaces and use as key. Still needs to be in
# extra_valid_entries to be used.
autokey = key.replace(' ','').lower()
for val in re.split("\s*,\s*", value):
self.story.addToList(autokey, val)
logger.debug("Auto metadata: entry:%s %s_label:%s value:%s" % (autokey, autokey, key, value))
def extractChapterUrlsAndMetadata(self):
printUrl = self.url + '&action=printable&textsize=0&chapter='

View file

@ -1545,6 +1545,24 @@ extracategories:Transgender
## confirm they are adult for adult content.
#is_adult:true
## This site has a number of additional site specific metadata
## entries. This is the first test case of base_efiction 'Auto
## metadata' automatically including unrecognized metadata. Still
## requires entries in extra_valid_entries to be used.
extra_valid_entries:turnedinto,featureditems,locale,motivationforchange,sexualorientation,storytheme,bodymodification,personality,storytype,typeofchange
#add_to_titlepage_entries:,turnedinto,featureditems,locale,motivationforchange,sexualorientation,storytheme,bodymodification,personality,storytype,typeofchange
turnedinto_label:Turned Into
featureditems_label:Featured Items
locale_label:Locale
motivationforchange_label:Motivation for Change
sexualorientation_label:Sexual Orientation
storytheme_label:Story Theme
bodymodification_label:Body Modification
personality_label:Personality
storytype_label:Story Type
typeofchange_label:Type of Change
[thehexfiles.net]
## Site dedicated to these categories/characters/ships
extracategories:Harry Potter