diff --git a/src/calibre/ebooks/mobi/reader/mobi6.py b/src/calibre/ebooks/mobi/reader/mobi6.py index eef167655e..1738347402 100644 --- a/src/calibre/ebooks/mobi/reader/mobi6.py +++ b/src/calibre/ebooks/mobi/reader/mobi6.py @@ -30,7 +30,12 @@ class TopazError(ValueError): class KFXError(ValueError): - pass + + def __init__(self): + ValueError.__init__(self, _( + 'This is an Amazon KFX book. It cannot be processed.' + ' See {} for information on how to handle KFX books.' + ).format('https://www.mobileread.com/forums/showthread.php?t=283371')) class MobiReader(object): @@ -76,7 +81,7 @@ class MobiReader(object): if raw.startswith('TPZ'): raise TopazError(_('This is an Amazon Topaz book. It cannot be processed.')) if raw.startswith(b'\xeaDRMION\xee'): - raise KFXError(_('This is an Amazon KFX book. It cannot be processed.')) + raise KFXError() self.header = raw[0:72] self.name = self.header[:32].replace('\x00', '') diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index b16f96d893..06dea6bbb8 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en' '''The main GUI''' -import collections, os, sys, textwrap, time, gc, errno +import collections, os, sys, textwrap, time, gc, errno, re from Queue import Queue, Empty from threading import Thread from collections import OrderedDict @@ -793,6 +793,19 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ self._modeless_dialogs.append(d) return + if 'calibre.ebooks.mobi.reader.mobi6.KFXError:' in job.details: + if not minz: + title = job.description.split(':')[-1].partition('(')[-1][:-1] + msg = _('
Failed to convert: %s') % title + idx = job.details.index('calibre.ebooks.mobi.reader.mobi6.KFXError:') + msg += '
' + re.sub(r'(https:\S+)', r'{}'.format(_('here')), + job.details[idx:].partition(':')[2].strip()) + d = error_dialog(self, _('Conversion Failed'), msg, det_msg=job.details) + d.setModal(False) + d.show() + self._modeless_dialogs.append(d) + return + if 'calibre.web.feeds.input.RecipeDisabled' in job.details: if not minz: msg = job.details