mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Input: Fix EPUB2 files that specify a cover image via a <meta> tag but not in the <guide> not getting a cover when converted to PDF
This commit is contained in:
parent
551bf6d74b
commit
92da68945a
@ -128,6 +128,7 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
means, at most one entry with type="cover" that points to a raster
|
means, at most one entry with type="cover" that points to a raster
|
||||||
cover and at most one entry with type="titlepage" that points to an
|
cover and at most one entry with type="titlepage" that points to an
|
||||||
HTML titlepage. '''
|
HTML titlepage. '''
|
||||||
|
from calibre.ebooks.oeb.base import OPF
|
||||||
removed = None
|
removed = None
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
guide_cover, guide_elem = None, None
|
guide_cover, guide_elem = None, None
|
||||||
@ -136,6 +137,16 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
guide_cover = guide_elem.get('href', '').partition('#')[0]
|
guide_cover = guide_elem.get('href', '').partition('#')[0]
|
||||||
break
|
break
|
||||||
if not guide_cover:
|
if not guide_cover:
|
||||||
|
raster_cover = opf.raster_cover
|
||||||
|
if raster_cover:
|
||||||
|
if guide_elem is None:
|
||||||
|
g = opf.root.makeelement(OPF('guide'))
|
||||||
|
opf.root.append(g)
|
||||||
|
else:
|
||||||
|
g = guide_elem.getparent()
|
||||||
|
guide_cover = raster_cover
|
||||||
|
guide_elem = g.makeelement(OPF('reference'), attrib={'href':raster_cover, 'type':'cover'})
|
||||||
|
g.append(guide_elem)
|
||||||
return
|
return
|
||||||
spine = list(opf.iterspine())
|
spine = list(opf.iterspine())
|
||||||
if not spine:
|
if not spine:
|
||||||
@ -174,8 +185,6 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
# entry will be used by the epub output plugin, the raster cover entry
|
# entry will be used by the epub output plugin, the raster cover entry
|
||||||
# by other output plugins.
|
# by other output plugins.
|
||||||
|
|
||||||
from calibre.ebooks.oeb.base import OPF
|
|
||||||
|
|
||||||
# Search for a raster cover identified in the OPF
|
# Search for a raster cover identified in the OPF
|
||||||
raster_cover = opf.raster_cover
|
raster_cover = opf.raster_cover
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user