mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
653826f58a
commit
56a540f5f4
@ -27,6 +27,7 @@ class EXTHHeader(object): # {{{
|
|||||||
self.has_fake_cover = True
|
self.has_fake_cover = True
|
||||||
self.start_offset = None
|
self.start_offset = None
|
||||||
left = self.num_items
|
left = self.num_items
|
||||||
|
self.kf8_header = None
|
||||||
|
|
||||||
while left > 0:
|
while left > 0:
|
||||||
left -= 1
|
left -= 1
|
||||||
@ -95,6 +96,8 @@ class EXTHHeader(object): # {{{
|
|||||||
pass # ASIN or UUID
|
pass # ASIN or UUID
|
||||||
elif id == 116:
|
elif id == 116:
|
||||||
self.start_offset, = struct.unpack(b'>L', content)
|
self.start_offset, = struct.unpack(b'>L', content)
|
||||||
|
elif id == 121:
|
||||||
|
self.kf8_header, = struct.unpack(b'>L', content)
|
||||||
#else:
|
#else:
|
||||||
# print 'unhandled metadata record', id, repr(content)
|
# print 'unhandled metadata record', id, repr(content)
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -106,28 +106,29 @@ class MobiReader(object):
|
|||||||
self.name = self.name.decode(self.book_header.codec, 'replace')
|
self.name = self.name.decode(self.book_header.codec, 'replace')
|
||||||
self.kf8_type = None
|
self.kf8_type = None
|
||||||
is_kf8 = self.book_header.mobi_version == 8
|
is_kf8 = self.book_header.mobi_version == 8
|
||||||
|
k8i = getattr(self.book_header.exth, 'kf8_header', None)
|
||||||
|
|
||||||
if is_kf8:
|
if is_kf8:
|
||||||
self.kf8_type = 'standalone'
|
self.kf8_type = 'standalone'
|
||||||
else: # Check for joint mobi 6 and kf 8 file
|
elif k8i is not None: # Check for joint mobi 6 and kf 8 file
|
||||||
KF8_BOUNDARY = b'BOUNDARY'
|
|
||||||
for i, x in enumerate(self.sections[:-1]):
|
|
||||||
sec = x[0]
|
|
||||||
if (len(sec) == len(KF8_BOUNDARY) and sec ==
|
|
||||||
KF8_BOUNDARY):
|
|
||||||
try:
|
try:
|
||||||
self.book_header = BookHeader(self.sections[i+1][0],
|
raw = self.sections[k8i-1][0]
|
||||||
|
except:
|
||||||
|
raw = None
|
||||||
|
if raw == b'BOUNDARY':
|
||||||
|
try:
|
||||||
|
self.book_header = BookHeader(self.sections[k8i][0],
|
||||||
self.ident, user_encoding, self.log)
|
self.ident, user_encoding, self.log)
|
||||||
# The following are only correct in the Mobi 6
|
# The following are only correct in the Mobi 6
|
||||||
# header not the Mobi 8 header
|
# header not the Mobi 8 header
|
||||||
for x in ('first_image_index',):
|
for x in ('first_image_index',):
|
||||||
setattr(self.book_header, x, getattr(bh, x))
|
setattr(self.book_header, x, getattr(bh, x))
|
||||||
if hasattr(self.book_header, 'huff_offset'):
|
if hasattr(self.book_header, 'huff_offset'):
|
||||||
self.book_header.huff_offset += i + 1
|
self.book_header.huff_offset += k8i
|
||||||
self.kf8_type = 'joint'
|
self.kf8_type = 'joint'
|
||||||
self.kf8_boundary = i
|
self.kf8_boundary = k8i-1
|
||||||
except:
|
except:
|
||||||
self.book_header = bh
|
self.book_header = bh
|
||||||
break
|
|
||||||
|
|
||||||
def check_for_drm(self):
|
def check_for_drm(self):
|
||||||
if self.book_header.encryption_type != 0:
|
if self.book_header.encryption_type != 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user