Get Books: Amazon fix prices not being found. B&N fix details link. ebooks.com: fix cover image. Website changes to various EU stores

This commit is contained in:
Kovid Goyal 2012-04-30 00:46:09 +05:30
commit 96586de006
13 changed files with 34 additions and 31 deletions

View File

@ -1538,7 +1538,7 @@ class StoreWaterstonesUKStore(StoreBase):
headquarters = 'UK'
formats = ['EPUB', 'PDF']
affiliate = True
affiliate = False
class StoreWeightlessBooksStore(StoreBase):
name = 'Weightless Books'

View File

@ -68,9 +68,9 @@ class AmazonDEKindleStore(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath('.//a[@class="title"]/text()'))
price = ''.join(data.xpath('.//span[@class="price"]/text()'))
price = ''.join(data.xpath('.//div[@class="newPrice"]/span[contains(@class, "price")]/text()'))
author = ''.join(data.xpath('.//div[@class="title"]/span[@class="ptBrand"]/text()'))
author = ''.join(data.xpath('.//h3[@class="title"]/span[@class="ptBrand"]/text()'))
if author.startswith('von '):
author = author[4:]

View File

@ -64,8 +64,8 @@ class AmazonESKindleStore(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath('.//a[@class="title"]/text()'))
price = ''.join(data.xpath('.//span[@class="price"]/text()'))
author = unicode(''.join(data.xpath('.//div[@class="title"]/span[@class="ptBrand"]/text()')))
price = ''.join(data.xpath('.//div[@class="newPrice"]/span[contains(@class, "price")]/text()'))
author = unicode(''.join(data.xpath('.//h3[@class="title"]/span[@class="ptBrand"]/text()')))
if author.startswith('de '):
author = author[3:]

View File

@ -65,8 +65,8 @@ class AmazonFRKindleStore(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath('.//a[@class="title"]/text()'))
price = ''.join(data.xpath('.//span[@class="price"]/text()'))
author = unicode(''.join(data.xpath('.//div[@class="title"]/span[@class="ptBrand"]/text()')))
price = ''.join(data.xpath('.//div[@class="newPrice"]/span[contains(@class, "price")]/text()'))
author = unicode(''.join(data.xpath('.//h3[@class="title"]/span[@class="ptBrand"]/text()')))
if author.startswith('de '):
author = author[3:]

View File

@ -64,8 +64,8 @@ class AmazonITKindleStore(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath('.//a[@class="title"]/text()'))
price = ''.join(data.xpath('.//span[@class="price"]/text()'))
author = unicode(''.join(data.xpath('.//div[@class="title"]/span[@class="ptBrand"]/text()')))
price = ''.join(data.xpath('.//div[@class="newPrice"]/span[contains(@class, "price")]/text()'))
author = unicode(''.join(data.xpath('.//h3[@class="title"]/span[@class="ptBrand"]/text()')))
if author.startswith('di '):
author = author[3:]

View File

@ -147,7 +147,7 @@ class AmazonKindleStore(StorePlugin):
asin_xpath = './/div[@class="image"]/a[1]'
cover_xpath = './/img[@class="productImage"]/@src'
title_xpath = './/a[@class="title"]/text()'
price_xpath = './/span[@class="price"]/text()'
price_xpath = './/span[contains(@class, "price")]/text()'
# Old style list. Search "martin"
else:
data_xpath = '//div[contains(@class, "result")]'

View File

@ -64,9 +64,9 @@ class AmazonUKKindleStore(StorePlugin):
cover_url = ''.join(data.xpath(cover_xpath))
title = ''.join(data.xpath('.//a[@class="title"]/text()'))
price = ''.join(data.xpath('.//span[@class="price"]/text()'))
price = ''.join(data.xpath('.//div[@class="newPrice"]/span[contains(@class, "price")]/text()'))
author = ''.join(data.xpath('.//div[@class="title"]/span[@class="ptBrand"]/text()'))
author = ''.join(data.xpath('.//h3[@class="title"]/span[@class="ptBrand"]/text()'))
if author.startswith('by '):
author = author[3:]

View File

@ -7,6 +7,7 @@ __copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en'
import random
import urllib
from contextlib import closing
from lxml import html
@ -28,23 +29,27 @@ class BNStore(BasicStoreConfig, StorePlugin):
if random.randint(1, 10) in (1, 2, 3):
pub_id = '0dsO3kDu/AU'
base_url = 'http://click.linksynergy.com/fs-bin/click?id=%s&subid=&offerid=229293.1&type=10&tmpid=8433&RD_PARM1=' % pub_id
url = base_url + 'http%253A%252F%252Fwww.barnesandnoble.com%252F'
murl = 'http://click.linksynergy.com/fs-bin/click?id=%s&offerid=239662.13&type=3&subid=0' % pub_id
if detail_item:
detail_item = base_url + detail_item
purl = 'http://click.linksynergy.com/fs-bin/click?id=%s&subid=&offerid=239662.%s&type=2&subid=0' % (pub_id, detail_item)
url = purl
else:
purl = None
url = murl
#print(url)
if external or self.config.get('open_external', False):
open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))
open_url(QUrl(url_slash_cleaner(url)))
else:
d = WebStoreDialog(self.gui, url, parent, detail_item)
d = WebStoreDialog(self.gui, murl, parent, purl)
d.setWindowTitle(self.name)
d.set_tags(self.config.get('tags', ''))
d.exec_()
def search(self, query, max_results=10, timeout=60):
query = query.replace(' ', '-')
url = 'http://www.barnesandnoble.com/s/%s?store=nookstore' % query
url = 'http://www.barnesandnoble.com/s/%s?keyword=%s&store=ebook' % (query.replace(' ', '-'), urllib.quote_plus(query))
br = browser()
@ -55,9 +60,10 @@ class BNStore(BasicStoreConfig, StorePlugin):
if counter <= 0:
break
id = ''.join(data.xpath('.//a[contains(@class, "thumb")]/@href'))
id = ''.join(data.xpath('.//div[contains(@class, "display-tile-item")]/@data-bn-ean'))
if not id:
continue
cover_url = ''.join(data.xpath('.//img[contains(@class, "product-image")]/@src'))
title = ''.join(data.xpath('.//a[@class="title"]//text()'))

View File

@ -64,11 +64,7 @@ class EbookscomStore(BasicStoreConfig, StorePlugin):
continue
id = mo.group()
cover_url = ''
cover_load = ''.join(data.xpath('.//div[@class="img"]//img/@onload'))
mo = re.search('(?<=\').+?(?=\')', cover_load)
if mo:
cover_url = mo.group();
cover_url = ''.join(data.xpath('.//div[@class="img"]//img/@src'))
title = ''
author = ''

View File

@ -42,6 +42,7 @@ class EBookShoppeUKStore(BasicStoreConfig, StorePlugin):
def search(self, query, max_results=10, timeout=60):
url = 'http://www.ebookshoppe.com/search.php?search_query=' + urllib2.quote(query)
br = browser()
br.addheaders = [("Referer", "http://www.ebookshoppe.com/")]
counter = max_results
with closing(br.open(url, timeout=timeout)) as f:

View File

@ -25,16 +25,15 @@ class FoylesUKStore(BasicStoreConfig, StorePlugin):
def open(self, parent=None, detail_item=None, external=False):
url = 'http://www.awin1.com/awclick.php?mid=1414&id=120917'
detail_url = 'http://www.awin1.com/cread.php?awinmid=1414&awinaffid=120917&clickref=&p='
url_redirect = 'http://www.foyles.co.uk'
if external or self.config.get('open_external', False):
if detail_item:
url = detail_url + url_redirect + detail_item
url = detail_url + detail_item
open_url(QUrl(url_slash_cleaner(url)))
else:
detail_url = None
if detail_item:
detail_url = url + url_redirect + detail_item
detail_url = url + detail_item
d = WebStoreDialog(self.gui, url, parent, detail_url)
d.setWindowTitle(self.name)
d.set_tags(self.config.get('tags', ''))

View File

@ -59,7 +59,7 @@ class LibreDEStore(BasicStoreConfig, StorePlugin):
id = ''.join(details.xpath('./div[@class="text"]/a/@name')).strip()
if not id:
continue
cover_url = ''.join(details.xpath('./div[@class="bild"]/a/img/@src'))
cover_url = ''.join(details.xpath('.//div[@class="coverImg"]/a/img/@src'))
title = ''.join(details.xpath('./div[@class="text"]/span[@class="titel"]/a/text()')).strip()
author = ''.join(details.xpath('./div[@class="text"]/span[@class="author"]/text()')).strip()
pdf = details.xpath(
@ -68,7 +68,8 @@ class LibreDEStore(BasicStoreConfig, StorePlugin):
'boolean(.//span[@class="format" and contains(text(), "epub")]/text())')
mobi = details.xpath(
'boolean(.//span[@class="format" and contains(text(), "mobipocket")]/text())')
price = (''.join(data.xpath('.//span[@class="preis"]/text()'))).replace('*', '')
price = ''.join(data.xpath('.//span[@class="preis"]/text()')).replace('*', '').strip()
counter -= 1
s = SearchResult()

View File

@ -41,7 +41,7 @@ class WHSmithUKStore(BasicStoreConfig, StorePlugin):
def search(self, query, max_results=10, timeout=60):
url = ('http://www.whsmith.co.uk/CatalogAndSearch/SearchWithinCategory.aspx'
'?cat=\Books\eb_eBooks&gq=' + urllib2.quote(query))
'?cat=\eb_eBooks&gq=' + urllib2.quote(query))
br = browser()