From c74dba472a69c79d2dc7675b92d40693ac162040 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 29 Jan 2026 14:55:24 -0600 Subject: [PATCH] Fixes for mutable metadata entries used in code --- fanficfare/adapters/adapter_adultfanfictionorg.py | 2 +- fanficfare/adapters/adapter_bloodshedversecom.py | 2 +- fanficfare/adapters/adapter_fanficauthorsnet.py | 4 ++-- fanficfare/adapters/adapter_fanficsme.py | 2 +- fanficfare/adapters/adapter_fictionlive.py | 2 +- fanficfare/adapters/adapter_ficwadcom.py | 2 +- fanficfare/adapters/adapter_fimfictionnet.py | 3 ++- fanficfare/adapters/adapter_literotica.py | 2 +- fanficfare/adapters/adapter_masseffect2in.py | 2 +- fanficfare/adapters/base_efiction_adapter.py | 2 +- 10 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fanficfare/adapters/adapter_adultfanfictionorg.py b/fanficfare/adapters/adapter_adultfanfictionorg.py index 4f47e7bd..f9f5f539 100644 --- a/fanficfare/adapters/adapter_adultfanfictionorg.py +++ b/fanficfare/adapters/adapter_adultfanfictionorg.py @@ -359,7 +359,7 @@ class AdultFanFictionOrgAdapter(BaseSiteAdapter): # Since the date is showing as 0000, # or there is -00- in the date, # I'm going to put the Published date here - self.story.setMetadata('dateUpdated', self.story.getMetadata('datPublished')) + self.story.setMetadata('dateUpdated', self.story.getMetadataRaw('datePublished')) else: self.story.setMetadata('dateUpdated', makeDate(stripHTML(value), self.dateformat)) else: diff --git a/fanficfare/adapters/adapter_bloodshedversecom.py b/fanficfare/adapters/adapter_bloodshedversecom.py index 0e06ba23..21b6e349 100644 --- a/fanficfare/adapters/adapter_bloodshedversecom.py +++ b/fanficfare/adapters/adapter_bloodshedversecom.py @@ -174,7 +174,7 @@ class BloodshedverseComAdapter(BaseSiteAdapter): # ugly %p(am/pm) hack moved into makeDate so other sites can use it. self.story.setMetadata('dateUpdated', date) - if self.story.getMetadata('rating') == 'NC-17' and not (self.is_adult or self.getConfig('is_adult')): + if self.story.getMetadataRaw('rating') == 'NC-17' and not (self.is_adult or self.getConfig('is_adult')): raise exceptions.AdultCheckRequired(self.url) def getChapterText(self, url): diff --git a/fanficfare/adapters/adapter_fanficauthorsnet.py b/fanficfare/adapters/adapter_fanficauthorsnet.py index 84767aff..2d9dbc5b 100644 --- a/fanficfare/adapters/adapter_fanficauthorsnet.py +++ b/fanficfare/adapters/adapter_fanficauthorsnet.py @@ -202,7 +202,7 @@ class FanficAuthorsNetAdapter(BaseSiteAdapter): ## Raising AdultCheckRequired after collecting chapters gives ## a double chapter list. So does genre, but it de-dups ## automatically. - if( self.story.getMetadata('rating') == 'Mature' + if( self.story.getMetadataRaw('rating') in ['Mature','Adult Only'] and not (self.is_adult or self.getConfig("is_adult")) ): raise exceptions.AdultCheckRequired(self.url) @@ -226,7 +226,7 @@ class FanficAuthorsNetAdapter(BaseSiteAdapter): # grab the text for an individual chapter. def getChapterText(self, url): logger.debug('Getting chapter text from: %s' % url) - if( self.story.getMetadata('rating') == 'Mature' and + if( self.story.getMetadataRaw('rating') in ['Mature','Adult Only'] and (self.is_adult or self.getConfig("is_adult")) ): addurl = "?bypass=1" else: diff --git a/fanficfare/adapters/adapter_fanficsme.py b/fanficfare/adapters/adapter_fanficsme.py index 112affc5..f736463d 100644 --- a/fanficfare/adapters/adapter_fanficsme.py +++ b/fanficfare/adapters/adapter_fanficsme.py @@ -150,7 +150,7 @@ class FanFicsMeAdapter(BaseSiteAdapter): self.story.setMetadata('rating',stripHTML(get_meta_content(u'Рейтинг'))) ## Need to login for any rating higher than General. - if self.story.getMetadata('rating') != 'General' and self.needToLoginCheck(data): + if self.story.getMetadataRaw('rating') != 'General' and self.needToLoginCheck(data): self.performLogin(url) # reload after login. data = self.get_request(url,usecache=False) diff --git a/fanficfare/adapters/adapter_fictionlive.py b/fanficfare/adapters/adapter_fictionlive.py index 1443d8fc..e45bdab8 100644 --- a/fanficfare/adapters/adapter_fictionlive.py +++ b/fanficfare/adapters/adapter_fictionlive.py @@ -173,7 +173,7 @@ class FictionLiveAdapter(BaseSiteAdapter): tags = data['ta'] if 'ta' in data else [] - if (self.story.getMetadata('rating') in {"nsfw", "adult"} or 'smut' in tags) and \ + if (self.story.getMetadataRaw('rating') in {"nsfw", "adult"} or 'smut' in tags) and \ not (self.is_adult or self.getConfig("is_adult")): raise exceptions.AdultCheckRequired(self.url) diff --git a/fanficfare/adapters/adapter_ficwadcom.py b/fanficfare/adapters/adapter_ficwadcom.py index 2ff078b6..694a759e 100644 --- a/fanficfare/adapters/adapter_ficwadcom.py +++ b/fanficfare/adapters/adapter_ficwadcom.py @@ -114,7 +114,7 @@ class FicwadComSiteAdapter(BaseSiteAdapter): titleh4 = soup.find('div',{'class':'storylist'}).find('h4') self.story.setMetadata('title', stripHTML(titleh4.a)) - if 'Deleted story' in self.story.getMetadata('title'): + if 'Deleted story' in self.story.getMetadataRaw('title'): raise exceptions.StoryDoesNotExist("This story was deleted. %s"%self.url) # Find authorid and URL from... author url. diff --git a/fanficfare/adapters/adapter_fimfictionnet.py b/fanficfare/adapters/adapter_fimfictionnet.py index 634efe59..c7def71e 100644 --- a/fanficfare/adapters/adapter_fimfictionnet.py +++ b/fanficfare/adapters/adapter_fimfictionnet.py @@ -151,7 +151,8 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter): self.story.setMetadata("authorId", author['href'].split('/')[2]) self.story.setMetadata("authorUrl", "https://%s/user/%s/%s" % (self.getSiteDomain(), self.story.getMetadata('authorId'), - self.story.getMetadata('author'))) + # meta entry author can be changed by the user. + stripHTML(author))) #Rating text is replaced with full words for historical compatibility after the site changed #on 2014-10-27 diff --git a/fanficfare/adapters/adapter_literotica.py b/fanficfare/adapters/adapter_literotica.py index f143f986..a6b45ff4 100644 --- a/fanficfare/adapters/adapter_literotica.py +++ b/fanficfare/adapters/adapter_literotica.py @@ -99,7 +99,7 @@ class LiteroticaSiteAdapter(BaseSiteAdapter): ## apply clean_chapter_titles def add_chapter(self,chapter_title,url,othermeta={}): if self.getConfig("clean_chapter_titles"): - storytitle = self.story.getMetadata('title').lower() + storytitle = self.story.getMetadataRaw('title').lower() chapter_name_type = None # strip trailing ch or pt before doing the chapter clean. # doesn't remove from story title metadata diff --git a/fanficfare/adapters/adapter_masseffect2in.py b/fanficfare/adapters/adapter_masseffect2in.py index be557b32..f2a3abab 100644 --- a/fanficfare/adapters/adapter_masseffect2in.py +++ b/fanficfare/adapters/adapter_masseffect2in.py @@ -162,7 +162,7 @@ class MassEffect2InAdapter(BaseSiteAdapter): self.story.extendList('authorId', [authorId]) self.story.extendList('authorUrl', [authorUrl]) - if not self.story.getMetadata('rating'): + if not self.story.getMetadataRaw('rating'): ratingTitle = chapter.getRatingTitle() if ratingTitle: self.story.setMetadata('rating', ratingTitle) diff --git a/fanficfare/adapters/base_efiction_adapter.py b/fanficfare/adapters/base_efiction_adapter.py index adc491f4..62ab7f74 100644 --- a/fanficfare/adapters/base_efiction_adapter.py +++ b/fanficfare/adapters/base_efiction_adapter.py @@ -446,7 +446,7 @@ class BaseEfictionAdapter(BaseSiteAdapter): if sn: self.story.setMetadata('storynotes', stripHTML(sn)) - if not self.story.getMetadata('rating'): + if not self.story.getMetadataRaw('rating'): self.getRatingFromTOC(); ## Chapter URLs