mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix amazon stores to account for website change.
This commit is contained in:
parent
c414e38d37
commit
9c41f1173a
@ -6,8 +6,6 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import random
|
|
||||||
import re
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
from lxml import html
|
from lxml import html
|
||||||
@ -130,7 +128,7 @@ class AmazonKindleStore(StorePlugin):
|
|||||||
|
|
||||||
data_xpath = '//div[contains(@class, "prod")]'
|
data_xpath = '//div[contains(@class, "prod")]'
|
||||||
format_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and not(contains(@class, "bld"))]/text()'
|
format_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and not(contains(@class, "bld"))]/text()'
|
||||||
asin_xpath = './/div[@class="image"]/a[1]'
|
asin_xpath = '@name'
|
||||||
cover_xpath = './/img[@class="productImage"]/@src'
|
cover_xpath = './/img[@class="productImage"]/@src'
|
||||||
title_xpath = './/h3[@class="newaps"]/a//text()'
|
title_xpath = './/h3[@class="newaps"]/a//text()'
|
||||||
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()'
|
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()'
|
||||||
@ -150,15 +148,9 @@ class AmazonKindleStore(StorePlugin):
|
|||||||
|
|
||||||
# We must have an asin otherwise we can't easily reference the
|
# We must have an asin otherwise we can't easily reference the
|
||||||
# book later.
|
# book later.
|
||||||
asin_href = None
|
asin = data.xpath(asin_xpath)
|
||||||
asin_a = data.xpath(asin_xpath)
|
if asin:
|
||||||
if asin_a:
|
asin = asin[0]
|
||||||
asin_href = asin_a[0].get('href', '')
|
|
||||||
m = re.search(r'/dp/(?P<asin>.+?)(/|$)', asin_href)
|
|
||||||
if m:
|
|
||||||
asin = m.group('asin')
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from lxml import html
|
from lxml import html
|
||||||
|
|
||||||
@ -53,7 +51,7 @@ class AmazonUKKindleStore(StorePlugin):
|
|||||||
|
|
||||||
data_xpath = '//div[contains(@class, "prod")]'
|
data_xpath = '//div[contains(@class, "prod")]'
|
||||||
format_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and not(contains(@class, "bld"))]/text()'
|
format_xpath = './/ul[contains(@class, "rsltL")]//span[contains(@class, "lrg") and not(contains(@class, "bld"))]/text()'
|
||||||
asin_xpath = './/div[@class="image"]/a[1]'
|
asin_xpath = '@name'
|
||||||
cover_xpath = './/img[@class="productImage"]/@src'
|
cover_xpath = './/img[@class="productImage"]/@src'
|
||||||
title_xpath = './/h3[@class="newaps"]/a//text()'
|
title_xpath = './/h3[@class="newaps"]/a//text()'
|
||||||
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()'
|
author_xpath = './/h3[@class="newaps"]//span[contains(@class, "reg")]/text()'
|
||||||
@ -73,15 +71,9 @@ class AmazonUKKindleStore(StorePlugin):
|
|||||||
|
|
||||||
# We must have an asin otherwise we can't easily reference the
|
# We must have an asin otherwise we can't easily reference the
|
||||||
# book later.
|
# book later.
|
||||||
asin_href = None
|
asin = data.xpath(asin_xpath)
|
||||||
asin_a = data.xpath(asin_xpath)
|
if asin:
|
||||||
if asin_a:
|
asin = asin[0]
|
||||||
asin_href = asin_a[0].get('href', '')
|
|
||||||
m = re.search(r'/dp/(?P<asin>.+?)(/|$)', asin_href)
|
|
||||||
if m:
|
|
||||||
asin = m.group('asin')
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user