From c915aceb85b82a245d9dcf0de9a715887f90a8d3 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 9 Apr 2024 10:57:34 -0500 Subject: [PATCH] basexf: Fix for prefix tags, put in prefixtags included in genre --- calibre-plugin/plugin-defaults.ini | 5 +++-- fanficfare/adapters/base_xenforo2forum_adapter.py | 13 +++++++------ fanficfare/defaults.ini | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index ebfd3bd7..25b99e98 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,contenttags,formattags,parentforums +add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,prefixtags,contenttags,formattags,parentforums ## '.NOREPL' tells the system to *not* apply title's ## in/exclude/replace_metadata -- Only works on include_in_ lines. @@ -760,6 +760,7 @@ tagsfromtitle_label:Tags from Title forumtags_label:Tags from Forum ## Note that forumtags also contains tags populated into category, ## genre, characters, contenttags and formattags +prefixtags_label:Prefix Tags from Forum contenttags_label:Content Tags from Forum formattags_label:Format Tags from Forum @@ -827,7 +828,7 @@ capitalize_forumtags:true ## Add forumtags to standard entry genre and tagsfromtitle to ## category. Can be changed in personal.ini if desired. -include_in_genre:genre,forumtags +include_in_genre:genre,forumtags,prefixtags include_in_category:category,tagsfromtitle,parentforums ## base_xenforoforum reads Published and Updated datetimes from diff --git a/fanficfare/adapters/base_xenforo2forum_adapter.py b/fanficfare/adapters/base_xenforo2forum_adapter.py index b5c4d538..46a73d60 100644 --- a/fanficfare/adapters/base_xenforo2forum_adapter.py +++ b/fanficfare/adapters/base_xenforo2forum_adapter.py @@ -89,12 +89,13 @@ class BaseXenForo2ForumAdapter(BaseXenForoForumAdapter): def parse_title(self,souptag): h1 = souptag.find('h1',{'class':'p-title-value'}) # logger.debug(h1) - ## SV has started putting 'Crossover', 'Sci-Fi' etc spans in the title h1. - for tag in h1.find_all('span',{'class':'label'}): - ## stick them into genre. - self.story.addToList('genre',stripHTML(tag)) - # logger.debug(stripHTML(tag)) - tag.extract() + ## April24 Prefix tags moved back out of title at some + ## point. This should probably be somewhere else + for tag in souptag.select("a[href*='prefix_id']"): + ## prefixtags included in genre in defaults.ini + self.story.addToList('prefixtags',stripHTML(tag)) + logger.debug("Prefix tag(%s)"%stripHTML(tag)) + # tag.extract() self.story.setMetadata('title',stripHTML(h1)) # logger.debug(stripHTML(h1)) diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 444e159b..9544abff 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,contenttags,formattags,parentforums +add_to_extra_valid_entries:,tagsfromtitledetect,tagsfromtitle,forumtags,prefixtags,contenttags,formattags,parentforums ## '.NOREPL' tells the system to *not* apply title's ## in/exclude/replace_metadata -- Only works on include_in_ lines. @@ -752,6 +752,7 @@ tagsfromtitle_label:Tags from Title forumtags_label:Tags from Forum ## Note that forumtags also contains tags populated into category, ## genre, characters, contenttags and formattags +prefixtags_label:Prefix Tags from Forum contenttags_label:Content Tags from Forum formattags_label:Format Tags from Forum @@ -819,7 +820,7 @@ capitalize_forumtags:true ## Add forumtags to standard entry genre and tagsfromtitle to ## category. Can be changed in personal.ini if desired. -include_in_genre:genre,forumtags +include_in_genre:genre,forumtags,prefixtags include_in_category:category,tagsfromtitle,parentforums ## base_xenforoforum reads Published and Updated datetimes from