From b31b4976988c6ef6233ee9f1a35bb7f01310d6dd Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 12 Mar 2012 21:43:29 -0500 Subject: [PATCH] portkeyorg- Write 'Chapter does not exist' chapter when chapter does not exist. --- fanficdownloader/adapters/adapter_portkeyorg.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fanficdownloader/adapters/adapter_portkeyorg.py b/fanficdownloader/adapters/adapter_portkeyorg.py index a03f0929..b13381b6 100644 --- a/fanficdownloader/adapters/adapter_portkeyorg.py +++ b/fanficdownloader/adapters/adapter_portkeyorg.py @@ -253,12 +253,15 @@ class PortkeyOrgAdapter(BaseSiteAdapter): # XXX def getChapterText(self, url): logging.debug('Getting chapter text from: %s' % url) - - soup = bs.BeautifulStoneSoup(self._fetchUrl(url), + data = self._fetchUrl(url) + soup = bs.BeautifulStoneSoup(data, selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags. #print("soup:%s"%soup) tag = soup.find('td', {'class' : 'story'}) + if tag == None and "
Chapter does not exist!
" in data: + print("Chapter is missing at: %s"%url) + return self.utf8FromSoup(url,bs.BeautifulStoneSoup("

Chapter does not exist!

Chapter is missing at: %s

"%(url,url))) tag.name='div' # force to be a div to avoid problems with nook. centers = tag.findAll('center')