From ded6f59c798c7f43f7cae192dccb1d0b0e974a70 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 10 Dec 2018 11:33:11 -0600 Subject: [PATCH] Workaround for adapter_hentaifoundrycom bad dateUpdated value. --- calibre-plugin/plugin-defaults.ini | 8 +++++++- fanficfare/adapters/adapter_hentaifoundrycom.py | 7 +++++++ fanficfare/defaults.ini | 8 +++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index e1035c47..709a7f07 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -2462,7 +2462,7 @@ add_to_titlepage_entries:,growth, shrink, sizeroles ## this should go in your personal.ini, not defaults.ini. #is_adult:true extra_valid_entries:comments,views,size,favs,vote_rating -extra_titlepage_entries:comments,views,size,favs,vote_rating +add_to_titlepage_entries:comments,views,size,favs,vote_rating comments_label:Comments views_label:Views @@ -2488,6 +2488,12 @@ vote_rating_label:Votes(Rating) ## datePublished_format #datechapter_format:%%Y-%%m-%%d +## Sometimes (perhaps often?) HF stories word counts and size are +## incorrect. You can exclude them from being used like so: +#add_to_exclude_metadata_pre: +# numWords=~.* +# size=~.* + [www.hpfanficarchive.com] ## Site dedicated to these categories/characters/ships extracategories:Harry Potter diff --git a/fanficfare/adapters/adapter_hentaifoundrycom.py b/fanficfare/adapters/adapter_hentaifoundrycom.py index d7baf13f..dbce2964 100644 --- a/fanficfare/adapters/adapter_hentaifoundrycom.py +++ b/fanficfare/adapters/adapter_hentaifoundrycom.py @@ -147,6 +147,7 @@ class HentaiFoundryComSiteAdapter(BaseSiteAdapter): 'Comments:':'comments', 'views:':'views', } + updateDate = self.story.getMetadataRaw('dateUpdated') boxbody = h1.find_next('div',class_='boxbody') for a in boxbody.find_all('a'): # @@ -165,9 +166,15 @@ class HentaiFoundryComSiteAdapter(BaseSiteAdapter): val = label.next_sibling.replace('•','').strip() # remove bullets. if l.endswith('date'): d = makeDate(val,self.dateformat) + if d > updateDate: + updateDate = d val = d.strftime(self.getConfig("datechapter_format",self.getConfig("datePublished_format","%Y-%m-%d"))) chap_meta[l] = val self.add_chapter(stripHTML(a),'https://'+self.host+a['href'],chap_meta) + ## site can screw up updated date, take from newest chapter date if greater. + if updateDate != self.story.getMetadataRaw('dateUpdated'): + self.story.setMetadata('dateUpdated',updateDate) + def getChapterText(self, url): diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index f374acce..9ca67d50 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -2490,7 +2490,7 @@ add_to_titlepage_entries:,growth, shrink, sizeroles ## this should go in your personal.ini, not defaults.ini. #is_adult:true extra_valid_entries:comments,views,size,favs,vote_rating -extra_titlepage_entries:comments,views,size,favs,vote_rating +add_to_titlepage_entries:comments,views,size,favs,vote_rating comments_label:Comments views_label:Views @@ -2516,6 +2516,12 @@ vote_rating_label:Votes(Rating) ## datePublished_format #datechapter_format:%%Y-%%m-%%d +## Sometimes (perhaps often?) HF stories word counts and size are +## incorrect. You can exclude them from being used like so: +#add_to_exclude_metadata_pre: +# numWords=~.* +# size=~.* + [www.hpfanficarchive.com] ## Site dedicated to these categories/characters/ships extracategories:Harry Potter