From eb45063d8351afb704d4aff32d4ed975754fff81 Mon Sep 17 00:00:00 2001 From: Serized Date: Sat, 17 Jun 2017 13:15:42 +0200 Subject: [PATCH 1/2] Update price detection X-path The price isn't presented in the same way as on the US store --- src/calibre/gui2/store/stores/amazon_fr_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/store/stores/amazon_fr_plugin.py b/src/calibre/gui2/store/stores/amazon_fr_plugin.py index 01bc7941b7..177690e607 100644 --- a/src/calibre/gui2/store/stores/amazon_fr_plugin.py +++ b/src/calibre/gui2/store/stores/amazon_fr_plugin.py @@ -68,7 +68,7 @@ def search_amazon(query, max_results=10, timeout=60, cover_xpath = "descendant-or-self::img[@class and contains(concat(' ', normalize-space(@class), ' '), ' s-access-image ')]/@src" title_xpath = "descendant-or-self::h2[@class and contains(concat(' ', normalize-space(@class), ' '), ' s-access-title ')]//text()" author_xpath = './/span[starts-with(text(), "%s ")]/following-sibling::span//text()' % BY - price_xpath = 'descendant::span[contains(@class, "sx-price")]/../@aria-label' + price_xpath = 'descendant::span[contains(@class, "s-price")]//text()' else: return From bb81194fcb08a503728875e8db209068df64dde4 Mon Sep 17 00:00:00 2001 From: Serized Date: Sat, 17 Jun 2017 13:16:53 +0200 Subject: [PATCH 2/2] Updated price detection Use price directly from the list of results rather than the details page. --- src/calibre/gui2/store/stores/ebooks_com_plugin.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/store/stores/ebooks_com_plugin.py b/src/calibre/gui2/store/stores/ebooks_com_plugin.py index 455c705113..ab798f4df0 100644 --- a/src/calibre/gui2/store/stores/ebooks_com_plugin.py +++ b/src/calibre/gui2/store/stores/ebooks_com_plugin.py @@ -70,12 +70,16 @@ class EbookscomStore(BasicStoreConfig, StorePlugin): if not title or not author: continue + price = ''.join(data.xpath( + './/span[starts-with(text(), "US$") or starts-with(text(), "€") or starts-with(text(), "CA$") or starts-with(text(), "AU$") or starts-with(text(), "£")]/text()')).strip() + counter -= 1 s = SearchResult() s.cover_url = cover_url s.title = title.strip() s.author = author.strip() + s.price = price.strip() s.detail_item = '?url=http://www.ebooks.com/cj.asp?IID=' + id.strip() + '&cjsku=' + id.strip() yield s @@ -94,11 +98,6 @@ class EbookscomStore(BasicStoreConfig, StorePlugin): with closing(br.open(url + id, timeout=timeout)) as nf: pdoc = html.fromstring(nf.read()) - price_l = pdoc.xpath('//div[@class="book-info"]/div[@class="price"]/text()') - if price_l: - price = price_l[0] - search_result.price = price.strip() - search_result.drm = SearchResult.DRM_UNLOCKED permissions = ' '.join(pdoc.xpath('//div[@class="permissions-items"]//text()')) if 'off' in permissions: