diff --git a/src/calibre/gui2/store/stores/cdp_plugin.py b/src/calibre/gui2/store/stores/cdp_plugin.py index 19b931b962..ff7605916b 100644 --- a/src/calibre/gui2/store/stores/cdp_plugin.py +++ b/src/calibre/gui2/store/stores/cdp_plugin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) -store_version = 1 # Needed for dynamic plugin loading +store_version = 2 # Needed for dynamic plugin loading __license__ = 'GPL 3' __copyright__ = '2013, Tomasz Długosz ' @@ -61,11 +61,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() @@ -75,9 +70,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 diff --git a/src/calibre/gui2/store/stores/koobe_plugin.py b/src/calibre/gui2/store/stores/koobe_plugin.py index 52bdd41e54..b8b7386593 100644 --- a/src/calibre/gui2/store/stores/koobe_plugin.py +++ b/src/calibre/gui2/store/stores/koobe_plugin.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import (division, absolute_import, print_function) +from __future__ import (unicode_literals, division, absolute_import, print_function) store_version = 3 # Needed for dynamic plugin loading __license__ = 'GPL 3' diff --git a/src/calibre/gui2/store/stores/legimi_plugin.py b/src/calibre/gui2/store/stores/legimi_plugin.py index 1195866faa..0af9220f75 100644 --- a/src/calibre/gui2/store/stores/legimi_plugin.py +++ b/src/calibre/gui2/store/stores/legimi_plugin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) -store_version = 2 # Needed for dynamic plugin loading +store_version = 3 # Needed for dynamic plugin loading __license__ = 'GPL 3' __copyright__ = '2011-2013, Tomasz Długosz ' @@ -45,7 +45,6 @@ class LegimiStore(BasicStoreConfig, StorePlugin): url = 'http://www.legimi.com/pl/ebooki/?szukaj=' + urllib.quote_plus(query) br = browser() - drm_pattern = re.compile("zabezpieczona DRM") counter = max_results with closing(br.open(url, timeout=timeout)) as f: @@ -62,14 +61,6 @@ class LegimiStore(BasicStoreConfig, StorePlugin): title = ''.join(data.xpath('.//span[@class="bookListTitle ellipsis"]/text()')) author = ''.join(data.xpath('.//span[@class="bookListAuthor ellipsis"]/text()')) price = ''.join(data.xpath('.//div[@class="bookListPrice"]/span/text()')) - formats = [] - with closing(br.open(id.strip(), timeout=timeout/4)) as nf: - idata = html.fromstring(nf.read()) - formatlist = idata.xpath('.//div[@id="fullBookFormats"]//span[@class="bookFormat"]/text()') - for x in formatlist: - if x.strip() not in formats: - formats.append(x.strip()) - drm = drm_pattern.search(''.join(idata.xpath('.//div[@id="fullBookFormats"]/p/text()'))) counter -= 1 @@ -79,7 +70,20 @@ class LegimiStore(BasicStoreConfig, StorePlugin): s.author = author.strip() s.price = price s.detail_item = 'http://www.legimi.com/' + id.strip() - s.formats = ', '.join(formats) - s.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED yield s + + def get_details(self, search_result, timeout): + drm_pattern = re.compile("zabezpieczona DRM") + formats = [] + br = browser() + with closing(br.open(search_result.detail_item, timeout=timeout)) as nf: + idata = html.fromstring(nf.read()) + formatlist = idata.xpath('.//div[@id="fullBookFormats"]//span[@class="bookFormat"]/text()') + for x in formatlist: + if x.strip() not in formats: + formats.append(x.strip()) + drm = drm_pattern.search(''.join(idata.xpath('.//div[@id="fullBookFormats"]/p/text()'))) + search_result.formats = ', '.join(formats) + search_result.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED + return True