mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get Books: Fix detection of author name from Amazon search results
Fixes #1895084 [Searching Amazon in "Get Books" fails](https://bugs.launchpad.net/calibre/+bug/1895084)
This commit is contained in:
parent
db1c0a117b
commit
754ebf854b
@ -3,7 +3,7 @@
|
|||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
store_version = 18 # Needed for dynamic plugin loading
|
store_version = 19 # Needed for dynamic plugin loading
|
||||||
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
try:
|
try:
|
||||||
@ -72,8 +72,8 @@ def search_amazon(query, max_results=10, timeout=60,
|
|||||||
title = etree.tostring(result.xpath('.//h2')[0], method='text', encoding='unicode')
|
title = etree.tostring(result.xpath('.//h2')[0], method='text', encoding='unicode')
|
||||||
adiv = result.xpath('.//div[contains(@class, "a-color-secondary")]')[0]
|
adiv = result.xpath('.//div[contains(@class, "a-color-secondary")]')[0]
|
||||||
aparts = etree.tostring(adiv, method='text', encoding='unicode').split()
|
aparts = etree.tostring(adiv, method='text', encoding='unicode').split()
|
||||||
idx = aparts.index('|')
|
idx = aparts.index('by')
|
||||||
author = ' '.join(aparts[1:idx])
|
author = ' '.join(aparts[idx+1:]).split('|')[0].strip()
|
||||||
price = ''
|
price = ''
|
||||||
for span in result.xpath('.//span[contains(@class, "a-price")]/span[contains(@class, "a-offscreen")]'):
|
for span in result.xpath('.//span[contains(@class, "a-price")]/span[contains(@class, "a-offscreen")]'):
|
||||||
q = ''.join(span.xpath('./text()'))
|
q = ''.join(span.xpath('./text()'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user