mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
EPUB Input: Handle EPUB files with incorrect media types for the spine items when converting. Fixes #1273471 [OEBError: Spine is empty](https://bugs.launchpad.net/calibre/+bug/1273471)
This commit is contained in:
parent
d09c93fc66
commit
9f0e13f60e
@ -15,7 +15,7 @@ from collections import defaultdict
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
from calibre.ebooks.oeb.base import OPF1_NS, OPF2_NS, OPF2_NSMAP, DC11_NS, \
|
from calibre.ebooks.oeb.base import OPF1_NS, OPF2_NS, OPF2_NSMAP, DC11_NS, \
|
||||||
DC_NSES, OPF, xml2text
|
DC_NSES, OPF, xml2text, XHTML_MIME
|
||||||
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, OEB_IMAGES, \
|
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, OEB_IMAGES, \
|
||||||
PAGE_MAP_MIME, JPEG_MIME, NCX_MIME, SVG_MIME
|
PAGE_MAP_MIME, JPEG_MIME, NCX_MIME, SVG_MIME
|
||||||
from calibre.ebooks.oeb.base import XMLDECL_RE, COLLAPSE_RE, \
|
from calibre.ebooks.oeb.base import XMLDECL_RE, COLLAPSE_RE, \
|
||||||
@ -325,7 +325,11 @@ class OEBReader(object):
|
|||||||
if item.media_type.lower() in OEB_DOCS and hasattr(item.data, 'xpath'):
|
if item.media_type.lower() in OEB_DOCS and hasattr(item.data, 'xpath'):
|
||||||
spine.add(item, elem.get('linear'))
|
spine.add(item, elem.get('linear'))
|
||||||
else:
|
else:
|
||||||
self.oeb.log.warn('The item %s is not a XML document.'
|
if hasattr(item.data, 'tag') and item.data.tag and item.data.tag.endswith('}html'):
|
||||||
|
item.media_type = XHTML_MIME
|
||||||
|
spine.add(item, elem.get('linear'))
|
||||||
|
else:
|
||||||
|
self.oeb.log.warn('The item %s is not a XML document.'
|
||||||
' Removing it from spine.'%item.href)
|
' Removing it from spine.'%item.href)
|
||||||
if len(spine) == 0:
|
if len(spine) == 0:
|
||||||
raise OEBError("Spine is empty")
|
raise OEBError("Spine is empty")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user