EPUB Input: Automatically strip entries of type application/text from the spine. Apparently there are EPUB production tools out there that create them. Fixes #884792 (Private bug)

This commit is contained in:
Kovid Goyal 2011-11-11 08:47:21 +05:30
parent 2bc0afd821
commit 8d319b7630

View File

@ -180,7 +180,7 @@ class EPUBInput(InputFormatPlugin):
for y in opf.itermanifest():
id_ = y.get('id', None)
if id_ and y.get('media-type', None) in \
('application/vnd.adobe-page-template+xml',):
('application/vnd.adobe-page-template+xml','application/text'):
not_for_spine.add(id_)
for x in list(opf.iterspine()):
@ -189,6 +189,9 @@ class EPUBInput(InputFormatPlugin):
x.getparent().remove(x)
continue
if len(list(opf.iterspine())) == 0:
raise ValueError('No valid entries in the spine of this EPUB')
with open('content.opf', 'wb') as nopf:
nopf.write(opf.render())