mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix ratings not being downloaded from Amazon
This commit is contained in:
parent
0fbf30487e
commit
68f63e807a
@ -154,17 +154,16 @@ def get_metadata(br, asin, mi):
|
|||||||
return False
|
return False
|
||||||
if root.xpath('//*[@id="errorMessage"]'):
|
if root.xpath('//*[@id="errorMessage"]'):
|
||||||
return False
|
return False
|
||||||
ratings = root.xpath('//form[@id="handleBuy"]/descendant::*[@class="asinReviewsSummary"]')
|
|
||||||
if ratings:
|
ratings = root.xpath('//div[@class="jumpBar"]/descendant::span[@class="asinReviewsSummary"]')
|
||||||
pat = re.compile(r'([0-9.]+) out of (\d+) stars')
|
pat = re.compile(r'([0-9.]+) out of (\d+) stars')
|
||||||
r = ratings[0]
|
if ratings:
|
||||||
for elem in r.xpath('descendant::*[@title]'):
|
for elem in ratings[0].xpath('descendant::*[@title]'):
|
||||||
t = elem.get('title')
|
t = elem.get('title').strip()
|
||||||
m = pat.match(t)
|
m = pat.match(t)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
try:
|
try:
|
||||||
mi.rating = float(m.group(1))/float(m.group(2)) * 5
|
mi.rating = float(m.group(1))/float(m.group(2)) * 5
|
||||||
break
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -216,6 +215,7 @@ def main(args=sys.argv):
|
|||||||
print 'Failed to downlaod social metadata for', title
|
print 'Failed to downlaod social metadata for', title
|
||||||
return 1
|
return 1
|
||||||
#print '\n\n', time.time() - st, '\n\n'
|
#print '\n\n', time.time() - st, '\n\n'
|
||||||
|
print mi
|
||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user