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:
|
for item in self.oeb.spine:
|
||||||
try:
|
try:
|
||||||
images = XPath('//h:img[@src]')(item.data)
|
images = XPath('//h:img[@src]')(item.data)
|
||||||
except:
|
except Exception:
|
||||||
images = []
|
images = ()
|
||||||
removed = False
|
removed = False
|
||||||
for img in images:
|
for img in images:
|
||||||
href = item.abshref(img.get('src'))
|
try:
|
||||||
|
href = item.abshref(img.get('src'))
|
||||||
|
except Exception:
|
||||||
|
continue # Invalid URL, ignore
|
||||||
if href == cover_item.href:
|
if href == cover_item.href:
|
||||||
img.getparent().remove(img)
|
img.getparent().remove(img)
|
||||||
removed = True
|
removed = True
|
||||||
@ -195,6 +198,3 @@ class MergeMetadata(object):
|
|||||||
' the cover image'%item.href)
|
' the cover image'%item.href)
|
||||||
self.oeb.spine.remove(item)
|
self.oeb.spine.remove(item)
|
||||||
self.oeb.manifest.remove(item)
|
self.oeb.manifest.remove(item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user