Store: Fix price detection for Google Books.

This commit is contained in:
John Schember 2012-02-18 12:44:28 -05:00
parent 91b181e5a9
commit ea2d72c2b9

View File

@ -93,16 +93,13 @@ class GoogleBooksStore(BasicStoreConfig, StorePlugin):
search_result.cover_url = ''.join(doc.xpath('//div[@class="sidebarcover"]//img/@src')) search_result.cover_url = ''.join(doc.xpath('//div[@class="sidebarcover"]//img/@src'))
# Try to get the set price. # Try to get the set price.
price = ''.join(doc.xpath('//div[@class="buy-price-container"]/span[contains(@class, "buy-price")]/text()')) price = ''.join(doc.xpath('//div[@id="gb-get-book-container"]//a/text()'))
# Try to get the price inside of a buy button. if 'read' in price.lower():
if not price.strip():
price = ''.join(doc.xpath('//div[@class="buy-container"]/a/text()'))
price = price.split('-')[-1]
if 'view' in price.lower():
price = 'Unknown' price = 'Unknown'
# No price set for this book. elif 'free' in price.lower() or not price.strip():
if not price.strip():
price = '$0.00' price = '$0.00'
elif '-' in price:
a, b, price = price.partition(' - ')
search_result.price = price.strip() search_result.price = price.strip()
search_result.formats = ', '.join(doc.xpath('//div[contains(@class, "download-panel-div")]//a/text()')).upper() search_result.formats = ', '.join(doc.xpath('//div[contains(@class, "download-panel-div")]//a/text()')).upper()