mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Do not error out when removing old cover if there are images with invalid URLs in the HTML
This commit is contained in:
parent
42b0acbfa3
commit
e1c0cbf9e4
@ -171,11 +171,14 @@ class MergeMetadata(object):
|
||||
for item in self.oeb.spine:
|
||||
try:
|
||||
images = XPath('//h:img[@src]')(item.data)
|
||||
except:
|
||||
images = []
|
||||
except Exception:
|
||||
images = ()
|
||||
removed = False
|
||||
for img in images:
|
||||
try:
|
||||
href = item.abshref(img.get('src'))
|
||||
except Exception:
|
||||
continue # Invalid URL, ignore
|
||||
if href == cover_item.href:
|
||||
img.getparent().remove(img)
|
||||
removed = True
|
||||
@ -195,6 +198,3 @@ class MergeMetadata(object):
|
||||
' the cover image'%item.href)
|
||||
self.oeb.spine.remove(item)
|
||||
self.oeb.manifest.remove(item)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user