From ed9e3ab4368965904cf64450c6175d27659bb54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Fri, 2 Aug 2013 23:34:11 +0200 Subject: [PATCH] move format detection to get_details() --- src/calibre/gui2/store/stores/cdp_plugin.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/store/stores/cdp_plugin.py b/src/calibre/gui2/store/stores/cdp_plugin.py index 738ee5e3d5..1aacd23d00 100644 --- a/src/calibre/gui2/store/stores/cdp_plugin.py +++ b/src/calibre/gui2/store/stores/cdp_plugin.py @@ -62,11 +62,6 @@ class CdpStore(BasicStoreConfig, StorePlugin): author = ''.join(data.xpath('.//div[@class="product-description"]//ul[@class="taxons"]/li[2]/a/text()')) price = ''.join(data.xpath('.//span[@itemprop="price"]/text()')) - with closing(br.open(id.strip(), timeout=timeout/4)) as nf: - idata = html.fromstring(nf.read()) - formats = ', '.join(idata.xpath('//div[@id="product-bonus"]/div/ul/li/text()')) - - counter -= 1 s = SearchResult() @@ -76,9 +71,16 @@ class CdpStore(BasicStoreConfig, StorePlugin): s.price = price s.detail_item = id.strip() s.drm = SearchResult.DRM_UNLOCKED - s.formats = formats.upper() yield s if not doc.xpath('//span[@class="next"]/a'): break page+=1 + + def get_details(self, search_result, timeout): + br = browser() + with closing(br.open(search_result.detail_item, timeout=timeout)) as nf: + idata = html.fromstring(nf.read()) + formats = ', '.join(idata.xpath('//div[@id="product-bonus"]/div/ul/li/text()')) + search_result.formats = formats.upper() + return True