Merge pull request #52 from t3d/stores

updates to polish plugins
This commit is contained in:
Kovid Goyal 2013-08-02 18:29:47 -07:00
commit ad5a5cc20e
3 changed files with 26 additions and 20 deletions

View File

@ -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 <tomek3d@gmail.com>'
@ -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

View File

@ -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'

View File

@ -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 <tomek3d@gmail.com>'
@ -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