From 5c078cac2a48cc7dd29db0ae2933b727a4d92ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Wed, 3 Oct 2012 21:38:10 +0200 Subject: [PATCH] update Woblink Store --- .../gui2/store/stores/woblink_plugin.py | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/calibre/gui2/store/stores/woblink_plugin.py b/src/calibre/gui2/store/stores/woblink_plugin.py index 1dc863700a..88d669fb9e 100644 --- a/src/calibre/gui2/store/stores/woblink_plugin.py +++ b/src/calibre/gui2/store/stores/woblink_plugin.py @@ -41,7 +41,7 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): d.exec_() def search(self, query, max_results=10, timeout=60): - url = 'http://woblink.com/publication?query=' + urllib.quote_plus(query.encode('utf-8')) + url = 'http://woblink.com/katalog-e-book?query=' + urllib.quote_plus(query.encode('utf-8')) if max_results > 10: if max_results > 20: url += '&limit=30' @@ -53,20 +53,20 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): counter = max_results with closing(br.open(url, timeout=timeout)) as f: doc = html.fromstring(f.read()) - for data in doc.xpath('//div[@class="book-item"]'): + for data in doc.xpath('//div[@class="book-item backgroundmix"]'): if counter <= 0: break - id = ''.join(data.xpath('.//td[@class="w10 va-t"]/a[1]/@href')) + id = ''.join(data.xpath('.//td[@class="w10 va-t mYHaveItYes"]/a[1]/@href')) if not id: continue - cover_url = ''.join(data.xpath('.//td[@class="w10 va-t"]/a[1]/img/@src')) + cover_url = ''.join(data.xpath('.//td[@class="w10 va-t mYHaveItYes"]/a[1]/img/@src')) title = ''.join(data.xpath('.//h2[@class="title"]/a[1]/text()')) - author = ', '.join(data.xpath('.//p[@class="author"]/a/text()')) - price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()')) + author = ', '.join(data.xpath('.//td[@class="va-t"]/h3/a/text()')) + price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/strong/span/text()')) price = re.sub('\.', ',', price) - formats = [ form[8:-4].split('_')[0] for form in data.xpath('.//p[3]/img/@src')] + formats = [ form[8:-4].split('.')[0] for form in data.xpath('.//p[3]/img/@src')] s = SearchResult() s.cover_url = 'http://woblink.com' + cover_url @@ -75,27 +75,24 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): s.price = price + ' zł' s.detail_item = id.strip() - # MOBI should be send first, - if 'MOBI' in formats: - t = copy.copy(s) - t.title += ' MOBI' - t.drm = SearchResult.DRM_UNLOCKED - t.formats = 'MOBI' - formats.remove('MOBI') - - counter -= 1 - yield t - - # and the remaining formats (if any) next - if formats: - if 'epub' in formats: - formats.remove('epub') - formats.append('WOBLINK') - if 'E Ink' in data.xpath('.//div[@class="prices"]/img/@title'): - formats.insert(0, 'EPUB') - + if 'epub_drm' in formats: s.drm = SearchResult.DRM_LOCKED - s.formats = ', '.join(formats).upper() - + s.formats = 'EPUB' + + counter -= 1 + yield s + elif 'pdf' in formats: + s.drm = SearchResult.DRM_LOCKED + s.formats = 'PDF' + + counter -= 1 + yield s + else: + s.drm = SearchResult.DRM_UNLOCKED + if 'MOBI_nieb' in formats: + formats.remove('MOBI_nieb') + formats.append('MOBI') + s.formats = ', '.join(formats).upper() + counter -= 1 yield s