From d8bf4242708450774591e5acc598979de4bb36ab Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 28 Feb 2012 13:27:02 -0600 Subject: [PATCH] Handle image errors, tweak desc of Update Cover option. --- calibre-plugin/config.py | 2 +- fanficdownloader/story.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index 7e2f89f..51ac66b 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -241,7 +241,7 @@ class BasicTab(QWidget): self.l.addWidget(self.updatemeta) self.updatecover = QCheckBox('Update Cover when Updating Metadata?',self) - self.updatecover.setToolTip('Update cover image when metadata is updated. EPUB only.') + self.updatecover.setToolTip("Update cover image from EPUB when metadata is updated. (EPUB only.)\nDoesn't go looking for new images on 'Update Calibre Metadata Only'.") self.updatecover.setChecked(prefs['updatecover']) self.l.addWidget(self.updatecover) diff --git a/fanficdownloader/story.py b/fanficdownloader/story.py index 11e3124..5964eb7 100644 --- a/fanficdownloader/story.py +++ b/fanficdownloader/story.py @@ -305,10 +305,15 @@ class Story: if imgurl not in self.imgurls: parsedUrl = urlparse.urlparse(imgurl) sizes = [ int(x) for x in configurable.getConfigList('image_max_size') ] - (data,ext,mime) = convert_image(imgurl, - fetch(imgurl), - sizes, - configurable.getConfig('grayscale_images')) + try: + (data,ext,mime) = convert_image(imgurl, + fetch(imgurl), + sizes, + configurable.getConfig('grayscale_images')) + except Exception, e: + print("Failed to load image, skipping:\n%s\nException: %s"%(imgurl,e)) + return "failedtoload" + # explicit cover, make the first image. if cover: if len(self.imgtuples) > 0 and 'cover' in self.imgtuples[0]['newsrc']: