Get Books: Fix clicking of results from Diesel books when there is only a single result not working

This commit is contained in:
Kovid Goyal 2012-08-17 09:24:51 +05:30
parent 8f076a4624
commit 036cea09d7

View File

@ -34,7 +34,10 @@ class DieselEbooksStore(BasicStoreConfig, StorePlugin):
detail_url = None detail_url = None
if detail_item: if detail_item:
detail_url = detail_item + aff_id if '?' in detail_item:
detail_url = detail_item + aff_id.replace('?', '&')
else:
detail_url = detail_item + aff_id
url = url + aff_id url = url + aff_id
if external or self.config.get('open_external', False): if external or self.config.get('open_external', False):
@ -52,9 +55,11 @@ class DieselEbooksStore(BasicStoreConfig, StorePlugin):
counter = max_results counter = max_results
with closing(br.open(url, timeout=timeout)) as f: with closing(br.open(url, timeout=timeout)) as f:
book_url = f.geturl()
doc = html.fromstring(f.read()) doc = html.fromstring(f.read())
if doc.xpath('not(boolean(//select[contains(@id, "selection")]))'): if doc.xpath('not(boolean(//select[contains(@id, "selection")]))'):
# This is the page for an individual book
id = ''.join(doc.xpath('//div[@class="price_fat"]//a/@href')) id = ''.join(doc.xpath('//div[@class="price_fat"]//a/@href'))
mo = re.search('(?<=id=).+?(?=&)', id) mo = re.search('(?<=id=).+?(?=&)', id)
if not mo: if not mo:
@ -79,7 +84,7 @@ class DieselEbooksStore(BasicStoreConfig, StorePlugin):
s.title = title.strip() s.title = title.strip()
s.author = author.strip() s.author = author.strip()
s.price = price.strip() s.price = price.strip()
s.detail_item = id.strip() s.detail_item = book_url
s.formats = formats s.formats = formats
s.drm = drm s.drm = drm