From a8d514092f5eda12f3adc9fe12ff252563ef9d18 Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Tue, 17 Feb 2009 15:45:42 -0800
Subject: [PATCH] Fix #1867 (Time magazine download failure)
---
src/calibre/ebooks/html.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py
index 3084aa67ad..b468e80246 100644
--- a/src/calibre/ebooks/html.py
+++ b/src/calibre/ebooks/html.py
@@ -493,7 +493,17 @@ class Parser(PreProcessor, LoggingInterface):
self.root.insert(0, head)
self.head = head
- self.body = self.root.body
+ try:
+ self.body = self.root.body
+ except:
+ import traceback
+ err = traceback.format_exc()
+ self.root = fromstring(u'
This page was too '
+ 'severely malformed for calibre to handle. '
+ 'It has been replaced by this error message.'
+ '
%s
'%err)
+ self.head = self.root.xpath('./head')[0]
+ self.body = self.root.body
for a in self.root.xpath('//a[@name]'):
a.set('id', a.get('name'))
if not self.head.xpath('./title'):