mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Another variant of Amazon cover markup
Seems to be user agent dependent
This commit is contained in:
parent
1c1aba239b
commit
68cc6ae288
@ -605,27 +605,27 @@ class Worker(Thread): # Get details {{{
|
|||||||
|
|
||||||
imgs = root.xpath('//img[(@id="prodImage" or @id="original-main-image" or @id="main-image" or @id="main-image-nonjs") and @src]')
|
imgs = root.xpath('//img[(@id="prodImage" or @id="original-main-image" or @id="main-image" or @id="main-image-nonjs") and @src]')
|
||||||
if not imgs:
|
if not imgs:
|
||||||
imgs = root.xpath('//div[@class="main-image-inner-wrapper"]/img[@src]')
|
imgs = (
|
||||||
if not imgs:
|
root.xpath('//div[@class="main-image-inner-wrapper"]/img[@src]') or
|
||||||
imgs = root.xpath('//div[@id="main-image-container"]//img[@src]')
|
root.xpath('//div[@id="main-image-container" or @id="ebooks-main-image-container"]//img[@src]') or
|
||||||
if not imgs:
|
root.xpath('//div[@id="mainImageContainer"]//img[@data-a-dynamic-image]')
|
||||||
imgs = root.xpath('//div[@id="mainImageContainer"]//img[@data-a-dynamic-image]')
|
)
|
||||||
for img in imgs:
|
for img in imgs:
|
||||||
try:
|
try:
|
||||||
idata = json.loads(img.get('data-a-dynamic-image'))
|
idata = json.loads(img.get('data-a-dynamic-image'))
|
||||||
except Exception:
|
except Exception:
|
||||||
imgs = ()
|
imgs = ()
|
||||||
else:
|
else:
|
||||||
mwidth = 0
|
mwidth = 0
|
||||||
try:
|
try:
|
||||||
url = None
|
url = None
|
||||||
for iurl, (width, height) in idata.iteritems():
|
for iurl, (width, height) in idata.iteritems():
|
||||||
if width > mwidth:
|
if width > mwidth:
|
||||||
mwidth = width
|
mwidth = width
|
||||||
url = iurl
|
url = iurl
|
||||||
return url
|
return url
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for img in imgs:
|
for img in imgs:
|
||||||
src = img.get('src')
|
src = img.get('src')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user