Apple driver: Handle invalid EPUBs that do not contain an OPF file

This commit is contained in:
Kovid Goyal 2011-04-30 08:24:54 -06:00
commit 309c85a14e

View File

@ -163,6 +163,8 @@ class ITUNES(DriverBase):
settings()
set_progress_reporter()
upload_books()
_get_fpath()
_update_epub_metadata()
add_books_to_metadata()
use_plugboard_ext()
set_plugboard()
@ -2621,16 +2623,13 @@ class ITUNES(DriverBase):
# Touch the OPF timestamp
try:
zf_opf = ZipFile(fpath,'r')
fnames = zf_opf.namelist()
opf = [x for x in fnames if '.opf' in x][0]
except:
raise UserFeedback("'%s' is not a valid EPUB" % metadata.title,
None,
level=UserFeedback.WARN)
fnames = zf_opf.namelist()
try:
opf = [x for x in fnames if '.opf' in x][0]
except:
opf = None
if opf:
opf_tree = etree.fromstring(zf_opf.read(opf))
md_els = opf_tree.xpath('.//*[local-name()="metadata"]')
if md_els: