diff --git a/src/calibre/ebooks/conversion/plugins/mobi_input.py b/src/calibre/ebooks/conversion/plugins/mobi_input.py index 9d71b69891..49a57cbde1 100644 --- a/src/calibre/ebooks/conversion/plugins/mobi_input.py +++ b/src/calibre/ebooks/conversion/plugins/mobi_input.py @@ -59,7 +59,10 @@ class MOBIInput(InputFormatPlugin): if mr.kf8_type is not None: log('Found KF8 MOBI of type %r'%mr.kf8_type) from calibre.ebooks.mobi.reader.mobi8 import Mobi8Reader - return os.path.abspath(Mobi8Reader(mr, log)()) + mr = Mobi8Reader(mr, log) + opf = os.path.abspath(mr()) + self.encrypted_fonts = mr.encrypted_fonts + return opf raw = parse_cache.pop('calibre_raw_mobi_markup', False) if raw: diff --git a/src/calibre/ebooks/mobi/reader/mobi8.py b/src/calibre/ebooks/mobi/reader/mobi8.py index 7939f51ccf..1e4d63d72e 100644 --- a/src/calibre/ebooks/mobi/reader/mobi8.py +++ b/src/calibre/ebooks/mobi/reader/mobi8.py @@ -33,6 +33,7 @@ class Mobi8Reader(object): def __init__(self, mobi6_reader, log): self.mobi6_reader, self.log = mobi6_reader, log self.header = mobi6_reader.book_header + self.encrypted_fonts = [] def __call__(self): self.mobi6_reader.check_for_drm() @@ -351,6 +352,8 @@ class Mobi8Reader(object): with open(href.replace('/', os.sep), 'wb') as f: f.write(font['font_data'] if font['font_data'] else font['raw_data']) + if font['encrypted']: + self.encrypted_fonts.append(href) else: imgtype = imghdr.what(None, data) if imgtype is None: diff --git a/src/calibre/ebooks/mobi/utils.py b/src/calibre/ebooks/mobi/utils.py index 2bab82bc53..4c1e52e119 100644 --- a/src/calibre/ebooks/mobi/utils.py +++ b/src/calibre/ebooks/mobi/utils.py @@ -437,7 +437,7 @@ def read_font_record(data, extent=1040): # {{{ # The zlib compressed data begins with 2 bytes of header and # has 4 bytes of checksum at the end ans = {'raw_data':data, 'font_data':None, 'err':None, 'ext':'failed', - 'headers':None} + 'headers':None, 'encrypted':False} try: usize, flags, dstart, xor_len, xor_start = struct.unpack_from( @@ -460,6 +460,7 @@ def read_font_record(data, extent=1040): # {{{ buf[n] ^= key[n%xor_len] # XOR of buf and key font_data = bytes(buf) + ans['encrypted'] = True if flags & 0b1: # ZLIB compressed data