From 6fcbdd8a8db3a92f0300c63fbf1312d730af2346 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sat, 3 May 2014 11:27:39 -0500 Subject: [PATCH] https for squidge.org/peja, allow story url change http to https on any site. --- calibre-plugin/ffdl_plugin.py | 3 ++- fanficdownloader/adapters/adapter_squidgeorgpeja.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index ec462bb6..dc42777d 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -970,7 +970,8 @@ class FanFictionDownLoaderPlugin(InterfaceAction): if book_id and mi: # book_id and mi only set if matched by title/author. liburl = self.get_story_url(db,book_id) if book['url'] != liburl and prefs['checkforurlchange'] and \ - not (book['url'].replace('https','http') == liburl and 'fanfiction.net' in liburl): + not (book['url'].replace('https','http') == liburl): # several sites have been changing to + # https now. Don't flag when that's the only change. # special case for ffnet urls change to https. if not question_dialog(self.gui, _('Change Story URL?'),'''

%s

diff --git a/fanficdownloader/adapters/adapter_squidgeorgpeja.py b/fanficdownloader/adapters/adapter_squidgeorgpeja.py index 713125fd..8ae9964b 100644 --- a/fanficdownloader/adapters/adapter_squidgeorgpeja.py +++ b/fanficdownloader/adapters/adapter_squidgeorgpeja.py @@ -62,7 +62,7 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter): # normalized story URL. - self._setURL('http://' + self.getSiteDomain() + '/peja/cgi-bin/viewstory.php?sid='+self.story.getMetadata('storyId')) + self._setURL('https://' + self.getSiteDomain() + '/peja/cgi-bin/viewstory.php?sid='+self.story.getMetadata('storyId')) # Each adapter needs to have a unique site abbreviation. self.story.setMetadata('siteabbrev','wwomb') @@ -83,10 +83,10 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter): @classmethod def getSiteExampleURLs(self): - return "http://"+self.getSiteDomain()+"/peja/cgi-bin/viewstory.php?sid=1234" + return "https://"+self.getSiteDomain()+"/peja/cgi-bin/viewstory.php?sid=1234" def getSiteURLPattern(self): - return re.escape("http://"+self.getSiteDomain()+"/")+"~?"+re.escape("peja/cgi-bin/viewstory.php?sid=")+r"\d+$" + return r"https?"+re.escape("://"+self.getSiteDomain()+"/")+r"~?"+re.escape("peja/cgi-bin/viewstory.php?sid=")+r"\d+$" ## Getting the chapter list and the meta data, plus 'is adult' checking. def extractChapterUrlsAndMetadata(self): @@ -116,7 +116,7 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter): # Find authorid and URL from... author url. author = soup.find('div', {'id':"pagetitle"}).find('a') self.story.setMetadata('authorId',author['href'].split('=')[1]) - self.story.setMetadata('authorUrl','http://'+self.host+'/peja/cgi-bin/'+author['href']) + self.story.setMetadata('authorUrl','https://'+self.host+'/peja/cgi-bin/'+author['href']) self.story.setMetadata('author',author.string) authorSoup = bs.BeautifulSoup(self._fetchUrl(self.story.getMetadata('authorUrl'))) @@ -131,7 +131,7 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter): chapterselect=soup.find('select',{'name':'chapter'}) if chapterselect: for ch in chapterselect.findAll('option'): - self.chapterUrls.append((stripHTML(ch),'http://'+self.host+'/peja/cgi-bin/viewstory.php?sid='+self.story.getMetadata('storyId')+'&chapter='+ch['value'])) + self.chapterUrls.append((stripHTML(ch),'https://'+self.host+'/peja/cgi-bin/viewstory.php?sid='+self.story.getMetadata('storyId')+'&chapter='+ch['value'])) else: self.chapterUrls.append((title,url)) @@ -207,7 +207,7 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter): # http://www.squidge.org/peja/cgi-bin/series.php?seriesid=254 a = titleblock.find('a', href=re.compile(r"series.php\?seriesid=\d+")) series_name = a.string - series_url = 'http://'+self.host+'/peja/cgi-bin/'+a['href'] + series_url = 'https://'+self.host+'/peja/cgi-bin/'+a['href'] # use BeautifulSoup HTML parser to make everything easier to find. seriessoup = bs.BeautifulSoup(self._fetchUrl(series_url))