This commit is contained in:
Kovid Goyal 2019-03-24 13:23:43 +05:30
parent 296eda53ea
commit 19d4a453e8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -101,7 +101,7 @@ def extract_calibre_cover(raw, base, log):
soup = BeautifulSoup(raw) soup = BeautifulSoup(raw)
matches = soup.find(name=['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', matches = soup.find(name=['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span',
'font', 'br']) 'font', 'br'])
images = soup.findAll('img') images = soup.findAll('img', src=True)
if matches is None and len(images) == 1 and \ if matches is None and len(images) == 1 and \
images[0].get('alt', '').lower()=='cover': images[0].get('alt', '').lower()=='cover':
img = images[0] img = images[0]
@ -119,7 +119,7 @@ def extract_calibre_cover(raw, base, log):
# Body has text, abort # Body has text, abort
return return
images = body.findAll('img', src=True) images = body.findAll('img', src=True)
if 0 < len(images) < 2: if len(images) == 1:
img = os.path.join(base, *images[0]['src'].split('/')) img = os.path.join(base, *images[0]['src'].split('/'))
return return_raster_image(img) return return_raster_image(img)