From 7df74c2bbb6507a65e1f771f75548adfb5043ed4 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 4 May 2022 16:32:42 -0500 Subject: [PATCH] adapter_wwwutopiastoriescom: Fixes for site changes. --- .../adapters/adapter_wwwutopiastoriescom.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fanficfare/adapters/adapter_wwwutopiastoriescom.py b/fanficfare/adapters/adapter_wwwutopiastoriescom.py index 75310e4b..12608a90 100644 --- a/fanficfare/adapters/adapter_wwwutopiastoriescom.py +++ b/fanficfare/adapters/adapter_wwwutopiastoriescom.py @@ -60,12 +60,12 @@ class WWWUtopiastoriesComAdapter(BaseSiteAdapter): self.is_adult=False # get storyId from url - self.story.setMetadata('storyId',self.parsedUrl.path.split('/')[-1]) + self.story.setMetadata('storyId',self.parsedUrl.path.split('/')[-1].replace('.html','')) # normalized story URL. - self._setURL('http://' + self.getSiteDomain() + '/code/show_story.asp/recid/' + - self.story.getMetadata('storyId')) + self._setURL('http://' + self.getSiteDomain() + '/code/show_story/recid/' + + self.story.getMetadata('storyId') + '.html') # Each adapter needs to have a unique site abbreviation. self.story.setMetadata('siteabbrev','gaggedutopia') @@ -84,11 +84,11 @@ class WWWUtopiastoriesComAdapter(BaseSiteAdapter): ################################################################################################ @classmethod def getSiteExampleURLs(cls): - return "http://"+cls.getSiteDomain()+"/code/show_story.asp/recid/1234" + return "http://"+cls.getSiteDomain()+"/code/show_story/recid/1234.html" ################################################################################################ def getSiteURLPattern(self): - return r"https?"+re.escape("://"+self.getSiteDomain()+"/code/show_story.asp/recid/")+r"\d+$" + return r"https?"+re.escape("://"+self.getSiteDomain())+r"/code/show_story(.asp)?/recid/\d+(.html)?$" ################################################################################################ def extractChapterUrlsAndMetadata(self): @@ -143,8 +143,8 @@ class WWWUtopiastoriesComAdapter(BaseSiteAdapter): else: self.story.setMetadata('authorId',a['href'].split('/')[2]) self.story.setMetadata('author',a.string) - self.story.setMetadata('authorUrl','http://'+self.host+quote( - a['href'].encode('UTF-8'))) + self.story.setMetadata('authorUrl','http://'+self.host+'/'+ + a['href'].replace('../..','code')) elif 'Story Codes' in heading: tags = text.replace('Story Codes - ','') for tag in tags.split(', '): @@ -174,7 +174,7 @@ class WWWUtopiastoriesComAdapter(BaseSiteAdapter): if self.story.getMetadata('author') != 'Unknown': adata = self.get_request(self.story.getMetadata('authorUrl')) asoup = self.make_soup(adata) - storyblock = asoup.find('a',href=re.compile(r"/code/show_story.asp/recid/"+ + storyblock = asoup.find('a',href=re.compile(r"/code/show_story/recid/"+ self.story.getMetadata('storyId'))) if storyblock != None: td = storyblock.findNext('td')