From 74ac96a67ec273eca865e11b49f6ed33d55f8251 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 1 Apr 2025 22:32:26 -0500 Subject: [PATCH] base_xenforoforum: Add timeperiodtags and better handle unexpected typed tags --- calibre-plugin/plugin-defaults.ini | 3 ++- fanficfare/adapters/base_xenforoforum_adapter.py | 10 +++++++--- fanficfare/defaults.ini | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index baf3a7b1..be90362e 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -769,7 +769,7 @@ author_avatar_cover:false strip_chapter_numbers:false ## Copy title to tagsfromtitle for parsing tags. -add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,prefixtags,contenttags,formattags,parentforums +add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,prefixtags,contenttags,formattags,timeperiodtags,parentforums ## '.NOREPL' tells the system to *not* apply title's ## in/exclude/replace_metadata -- Only works on include_in_ lines. @@ -783,6 +783,7 @@ forumtags_label:Tags from Forum prefixtags_label:Prefix Tags from Forum contenttags_label:Content Tags from Forum formattags_label:Format Tags from Forum +timeperiodtags_label:Time Period Tags from Forum parentforums_label:Parent Forums keep_in_order_parentforums:true diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index 9467e542..71b974bf 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -604,6 +604,7 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): 'Character':'characters', 'Content':'contenttags', 'Format':'formattags', + 'Time period':'timeperiodtags', } for tag in self.get_forumtags(topsoup): tagcat = tag.select_one("i") @@ -611,9 +612,12 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): if self.getConfig('capitalize_forumtags'): tstr = title(tstr) if tagcat: - tagname = tagmap[tagcat['title']] - # logger.debug("Forum Tag(%s) Cat(%s) list(%s)"%(stripHTML(tag),tagcat['title'],tagname)) - self.story.addToList(tagname,tstr) + tagname = tagmap.get(tagcat['title'],None) + if tagname: + # logger.debug("Forum Tag(%s) Cat(%s) list(%s)"%(stripHTML(tag),tagcat['title'],tagname)) + self.story.addToList(tagname,tstr) + else: + logger.debug("Forum Tag(%s) Cat(%s) tagname not found"%(stripHTML(tag),tagcat['title'])) # else: # logger.debug("Forum Tag(%s) Uncategorized"%stripHTML(tag)) self.story.addToList('forumtags',tstr) diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index ff69165c..163a8119 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -759,7 +759,7 @@ author_avatar_cover:false strip_chapter_numbers:false ## Copy title to tagsfromtitle for parsing tags. -add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,prefixtags,contenttags,formattags,parentforums +add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,prefixtags,contenttags,formattags,timeperiodtags,parentforums ## '.NOREPL' tells the system to *not* apply title's ## in/exclude/replace_metadata -- Only works on include_in_ lines. @@ -773,6 +773,7 @@ forumtags_label:Tags from Forum prefixtags_label:Prefix Tags from Forum contenttags_label:Content Tags from Forum formattags_label:Format Tags from Forum +timeperiodtags_label:Time Period Tags from Forum parentforums_label:Parent Forums keep_in_order_parentforums:true