mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1608 (Cover not found in Mobipocket file)
This commit is contained in:
parent
57111b4b93
commit
9cf9ccd52b
@ -33,7 +33,6 @@ class EXTHHeader(object):
|
|||||||
self.length, self.num_items = struct.unpack('>LL', raw[4:12])
|
self.length, self.num_items = struct.unpack('>LL', raw[4:12])
|
||||||
raw = raw[12:]
|
raw = raw[12:]
|
||||||
pos = 0
|
pos = 0
|
||||||
|
|
||||||
self.mi = MetaInformation('Unknown', ['Unknown'])
|
self.mi = MetaInformation('Unknown', ['Unknown'])
|
||||||
self.has_fake_cover = True
|
self.has_fake_cover = True
|
||||||
|
|
||||||
@ -49,6 +48,8 @@ class EXTHHeader(object):
|
|||||||
self.cover_offset, = struct.unpack('>L', content)
|
self.cover_offset, = struct.unpack('>L', content)
|
||||||
elif id == 202:
|
elif id == 202:
|
||||||
self.thumbnail_offset, = struct.unpack('>L', content)
|
self.thumbnail_offset, = struct.unpack('>L', content)
|
||||||
|
#else:
|
||||||
|
# print 'unknown record', id, repr(content)
|
||||||
title = re.search(r'\0+([^\0]+)\0+', raw[pos:])
|
title = re.search(r'\0+([^\0]+)\0+', raw[pos:])
|
||||||
if title:
|
if title:
|
||||||
self.mi.title = title.group(1).decode(codec, 'ignore')
|
self.mi.title = title.group(1).decode(codec, 'ignore')
|
||||||
@ -67,7 +68,8 @@ class EXTHHeader(object):
|
|||||||
if not self.mi.tags:
|
if not self.mi.tags:
|
||||||
self.mi.tags = []
|
self.mi.tags = []
|
||||||
self.mi.tags.append(content.decode(codec, 'ignore'))
|
self.mi.tags.append(content.decode(codec, 'ignore'))
|
||||||
|
#else:
|
||||||
|
# print 'unhandled metadata record', id, repr(content), codec
|
||||||
|
|
||||||
|
|
||||||
class BookHeader(object):
|
class BookHeader(object):
|
||||||
@ -466,6 +468,10 @@ def get_metadata(stream):
|
|||||||
cover = os.path.join(tdir, mi.cover)
|
cover = os.path.join(tdir, mi.cover)
|
||||||
if os.access(cover, os.R_OK):
|
if os.access(cover, os.R_OK):
|
||||||
mi.cover_data = ('JPEG', open(os.path.join(tdir, mi.cover), 'rb').read())
|
mi.cover_data = ('JPEG', open(os.path.join(tdir, mi.cover), 'rb').read())
|
||||||
|
else:
|
||||||
|
path = os.path.join(tdir, 'images', '00001.jpg')
|
||||||
|
if os.access(path, os.R_OK):
|
||||||
|
mi.cover_data = ('JPEG', open(path, 'rb').read())
|
||||||
return mi
|
return mi
|
||||||
|
|
||||||
def option_parser():
|
def option_parser():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user