Fix #9445 (PocketBook can't always find epub cover image to create thumbnail)

This commit is contained in:
Kovid Goyal 2011-03-18 13:23:42 -06:00
parent c22863b2da
commit e70550dc8a

View File

@ -38,6 +38,11 @@ class OEBOutput(OutputFormatPlugin):
except:
self.log.exception('Something went wrong while trying to'
' workaround Nook cover bug, ignoring')
try:
self.workaround_pocketbook_cover_bug(root)
except:
self.log.exception('Something went wrong while trying to'
' workaround Pocketbook cover bug, ignoring')
raw = etree.tostring(root, pretty_print=True,
encoding='utf-8', xml_declaration=True)
if key == OPF_MIME:
@ -90,3 +95,12 @@ class OEBOutput(OutputFormatPlugin):
cov.set('content', 'cover')
# }}}
def workaround_pocketbook_cover_bug(self, root): # {{{
m = root.xpath('//*[local-name() = "manifest"]/*[local-name() = "item" '
' and @id="cover"]')
if len(m) == 1:
m = m[0]
p = m.getparent()
p.remove(m)
p.insert(0, m)
# }}}