From 7a08e3afddb7fa6480f8f42910ab6a3dd32f001c Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sat, 6 Feb 2016 13:22:51 -0600 Subject: [PATCH] Add automatic adding of unrecognized metadata in base_efiction. For tgstorytime.com. --- calibre-plugin/plugin-defaults.ini | 18 ++++++++++++++++++ fanficfare/adapters/base_efiction_adapter.py | 8 +++++++- fanficfare/defaults.ini | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index e31ce526..14b164e2 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -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 diff --git a/fanficfare/adapters/base_efiction_adapter.py b/fanficfare/adapters/base_efiction_adapter.py index 72a25bf1..c6415701 100644 --- a/fanficfare/adapters/base_efiction_adapter.py +++ b/fanficfare/adapters/base_efiction_adapter.py @@ -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=' diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index cd64d7e5..081459f9 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -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