From e1cec84075a2ae94919f671ab4f0b489cb7cb3a4 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 9 Apr 2024 10:19:15 -0500 Subject: [PATCH] basexf: Add XF categorized tags into: category, genre, characters, contenttags and formattags --- calibre-plugin/plugin-defaults.ini | 10 ++++++++-- fanficfare/adapters/base_xenforoforum_adapter.py | 14 ++++++++++++++ fanficfare/defaults.ini | 10 ++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 9067ce8d..ebfd3bd7 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -749,7 +749,7 @@ author_avatar_cover:false strip_chapter_numbers:false ## Copy title to tagsfromtitle for parsing tags. -add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,parentforums +add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,contenttags,formattags,parentforums ## '.NOREPL' tells the system to *not* apply title's ## in/exclude/replace_metadata -- Only works on include_in_ lines. @@ -758,6 +758,11 @@ include_in_tagsfromtitle:tagsfromtitledetect tagsfromtitle_label:Tags from Title forumtags_label:Tags from Forum +## Note that forumtags also contains tags populated into category, +## genre, characters, contenttags and formattags +contenttags_label:Content Tags from Forum +formattags_label:Format Tags from Forum + parentforums_label:Parent Forums keep_in_order_parentforums:true @@ -816,7 +821,8 @@ add_to_extra_titlepage_entries:,tagsfromtitle,forumtags ## XenForo tags are all lowercase everywhere that I've seen. This ## makes the first letter of each word uppercase. Applied before -## replace_metadata. +## replace_metadata. Also applies to category, genre, characters, +## contenttags and formattags collected from site tags. capitalize_forumtags:true ## Add forumtags to standard entry genre and tagsfromtitle to diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index 797a3a71..3199f249 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -585,10 +585,24 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): if use_threadmark_chaps or self.getConfig('always_use_forumtags'): ## only use tags if threadmarks for chapters or always_use_forumtags is on. + tagmap = { + 'Setting':'category', + 'Genre':'genre', + 'Character':'characters', + 'Content':'contenttags', + 'Format':'formattags', + } for tag in self.get_forumtags(topsoup): + tagcat = tag.select_one("i") tstr = stripHTML(tag) 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) + else: + logger.debug("Forum Tag(%s) Uncategorized"%stripHTML(tag)) self.story.addToList('forumtags',tstr) # author moved down here to take from post URLs. diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index fdaada25..444e159b 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -741,7 +741,7 @@ author_avatar_cover:false strip_chapter_numbers:false ## Copy title to tagsfromtitle for parsing tags. -add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,parentforums +add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,contenttags,formattags,parentforums ## '.NOREPL' tells the system to *not* apply title's ## in/exclude/replace_metadata -- Only works on include_in_ lines. @@ -750,6 +750,11 @@ include_in_tagsfromtitle:tagsfromtitledetect tagsfromtitle_label:Tags from Title forumtags_label:Tags from Forum +## Note that forumtags also contains tags populated into category, +## genre, characters, contenttags and formattags +contenttags_label:Content Tags from Forum +formattags_label:Format Tags from Forum + parentforums_label:Parent Forums keep_in_order_parentforums:true @@ -808,7 +813,8 @@ add_to_extra_titlepage_entries:,tagsfromtitle,forumtags ## XenForo tags are all lowercase everywhere that I've seen. This ## makes the first letter of each word uppercase. Applied before -## replace_metadata. +## replace_metadata. Also applies to category, genre, characters, +## contenttags and formattags collected from site tags. capitalize_forumtags:true ## Add forumtags to standard entry genre and tagsfromtitle to