diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 3c995bbc..fd48a29e 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -675,6 +675,22 @@ always_use_forumtags:false ## be included in the word count if not also threadmarked. use_threadmark_wordcounts:true +## base_xenforoforum stories with threadmarks have a few additional +## pieces of metadata available that most adapters don't. 'date'; +## 'words'--word count as number only: "12104"; and kwords--the +## threadmark human-readable string for word count with parens: +## "(12.1k)" These can be used with custom output (see +## https://github.com/JimmXinu/FanFicFare/wiki/CustomOutput ) or with +## chapter_title_*_pattern settings. +## Example: +#tocpage_entry: +# ${chapter} ${date} ${kwords}
+ +## The 'date' value for chapters mentioned above can be formated with +## datethreadmark_format. Otherwise it will default to +## dateCreated_format +#datethreadmark_format:%%Y-%%m-%%d %%H:%%M + [base_xenforoforum:epub] ## See remove_spoilers above for more about 'spoilers'. This example diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index 87c99cdf..cf105a27 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -266,14 +266,20 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): date = self.make_date(atag.find_next_sibling('div',{'class':'extra'})) if atag.parent.has_attr('data-words'): words = int(atag.parent['data-words']) + if "(" in atag.next_sibling: + kwords = atag.next_sibling.strip() + # logger.debug("%s"%kwords) else: - words = None + words = "" + kwords = "" threadmarks.append({"tmcat_name":tmcat_name, "tmcat_num":tmcat_num, "tmcat_index":tmcat_index, "title":name, - "url":self.getURLPrefix()+"/"+url,"date":date, - "words":words}) + "url":self.getURLPrefix()+"/"+url, + "date":date, + "words":words, + "kwords":kwords}) return threadmarks @@ -350,7 +356,12 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): if 'tmcat_num' in tm and 'tmcat_index' in tm: self.threadmarks_for_reader[self.normalize_chapterurl(tm['url'])] = (tm['tmcat_num'],tm['tmcat_index']) - added = self.add_chapter(prepend+tm['title'],tm['url']) + ## threadmark date, words available for chapter custom output + ## date formate from datethreadmark_format or dateCreated_format + ## then a basic default. + added = self.add_chapter(prepend+tm['title'],tm['url'],{'date':tm['date'].strftime(self.getConfig("datethreadmark_format",self.getConfig("dateCreated_format","%Y-%m-%d %H:%M:%S"))), + 'words':tm['words'], + 'kwords':tm['kwords']}) if added and tm.get('words',None): words = words + tm['words'] diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 114dff25..9f601250 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -457,6 +457,7 @@ def get_valid_keywords(): 'internalize_text_links', 'replace_failed_smilies_with_alt_text', 'use_threadmark_wordcounts', + 'datethreadmark_format', 'fix_pseudo_html', 'fix_excess_space', 'ignore_chapter_url_list', diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 6cca7532..ad2f7479 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -702,6 +702,22 @@ always_use_forumtags:false ## be included in the word count if not also threadmarked. use_threadmark_wordcounts:true +## base_xenforoforum stories with threadmarks have a few additional +## pieces of metadata available that most adapters don't. 'date'; +## 'words'--word count as number only: "12104"; and kwords--the +## threadmark human-readable string for word count with parens: +## "(12.1k)" These can be used with custom output (see +## https://github.com/JimmXinu/FanFicFare/wiki/CustomOutput ) or with +## chapter_title_*_pattern settings. +## Example: +#tocpage_entry: +# ${chapter} ${date} ${kwords}
+ +## The 'date' value for chapters mentioned above can be formated with +## datethreadmark_format. Otherwise it will default to +## dateCreated_format +#datethreadmark_format:%%Y-%%m-%%d %%H:%%M + [base_xenforoforum:epub] ## See remove_spoilers above for more about 'spoilers'. This example