mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A friendlier error message with a link to the forum post when failing to convert a KFX book
This commit is contained in:
parent
4da1d75a42
commit
b64ebfa502
@ -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', '')
|
||||
|
@ -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 = _('<p><b>Failed to convert: %s') % title
|
||||
idx = job.details.index('calibre.ebooks.mobi.reader.mobi6.KFXError:')
|
||||
msg += '<p>' + re.sub(r'(https:\S+)', r'<a href="\1">{}</a>'.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
|
||||
|
Loading…
x
Reference in New Issue
Block a user