From ce02f5c4334fb19d0f0c6da0dde72994bd9fbe30 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Oct 2008 01:32:54 -0700 Subject: [PATCH] Fix #1105 (Wall St. Journal articles incomplete) --- src/calibre/web/feeds/news.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index bac117d628..6a9e9acd52 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -614,6 +614,8 @@ class BasicNewsRecipe(object, LoggingInterface): except NotImplementedError: feeds = self.parse_feeds() + #feeds = FeedCollection(feeds) + self.report_progress(0, _('Trying to download cover...')) self.download_cover() if self.test: @@ -675,6 +677,8 @@ class BasicNewsRecipe(object, LoggingInterface): except NoResultsPending: break + #feeds.restore_duplicates() + for f, feed in enumerate(feeds): html = self.feed2index(feed) feed_dir = os.path.join(self.output_dir, 'feed_%d'%f) @@ -745,20 +749,21 @@ class BasicNewsRecipe(object, LoggingInterface): entries.append(relp.replace(os.sep, '/')) last = sp - with open(last, 'rb') as fi: - src = fi.read().decode('utf-8') - soup = BeautifulSoup(src) - body = soup.find('body') - if body is not None: - prefix = '/'.join('..'for i in range(2*len(re.findall(r'link\d+', last)))) - templ = self.navbar.generate(True, num, j, len(f), - not self.has_single_feed, - a.orig_url, __appname__, prefix=prefix, - center=self.center_navbar) - elem = BeautifulSoup(templ.render(doctype='xhtml').decode('utf-8')).find('div') - body.insert(len(body.contents), elem) - with open(last, 'wb') as fi: - fi.write(unicode(soup).encode('utf-8')) + if os.path.exists(last): + with open(last, 'rb') as fi: + src = fi.read().decode('utf-8') + soup = BeautifulSoup(src) + body = soup.find('body') + if body is not None: + prefix = '/'.join('..'for i in range(2*len(re.findall(r'link\d+', last)))) + templ = self.navbar.generate(True, num, j, len(f), + not self.has_single_feed, + a.orig_url, __appname__, prefix=prefix, + center=self.center_navbar) + elem = BeautifulSoup(templ.render(doctype='xhtml').decode('utf-8')).find('div') + body.insert(len(body.contents), elem) + with open(last, 'wb') as fi: + fi.write(unicode(soup).encode('utf-8')) if len(feeds) > 1: for i, f in enumerate(feeds):