From b905d9cbb29ffec9b3c5fc6c3b9e4ca7e31448d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Wed, 21 Mar 2012 23:00:47 +0100 Subject: [PATCH 1/2] fix Woblink store, up to 30 items [Bat once --- src/calibre/customize/builtins.py | 2 +- .../gui2/store/stores/woblink_plugin.py | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 2908444665..d50a86e24a 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1574,7 +1574,7 @@ class StoreWoblinkStore(StoreBase): actual_plugin = 'calibre.gui2.store.stores.woblink_plugin:WoblinkStore' headquarters = 'PL' - formats = ['EPUB', 'PDF', 'WOBLINK'] + formats = ['EPUB', 'MOBI', 'PDF', 'WOBLINK'] class XinXiiStore(StoreBase): name = 'XinXii' diff --git a/src/calibre/gui2/store/stores/woblink_plugin.py b/src/calibre/gui2/store/stores/woblink_plugin.py index 9992c80eb9..022f48b95e 100644 --- a/src/calibre/gui2/store/stores/woblink_plugin.py +++ b/src/calibre/gui2/store/stores/woblink_plugin.py @@ -3,7 +3,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL 3' -__copyright__ = '2011, Tomasz Długosz ' +__copyright__ = '2011-2012, Tomasz Długosz ' __docformat__ = 'restructuredtext en' import re @@ -41,6 +41,11 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): def search(self, query, max_results=10, timeout=60): url = 'http://woblink.com/publication?query=' + urllib.quote_plus(query.encode('utf-8')) + if max_results > 10: + if max_results > 20: + url += '&limit=' + str(30) + else: + url += '&limit=' + str(20) br = browser() @@ -58,15 +63,14 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): cover_url = ''.join(data.xpath('.//td[@class="w10 va-t"]/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"]/p[1]/span/text()')) - price = re.sub('PLN', ' zł', price) + price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()')) price = re.sub('\.', ',', price) - formats = ', '.join(data.xpath('.//p[3]/img/@src')) - formats = formats[8:-4].upper() - if formats == 'EPUB': - formats = 'WOBLINK' + formats = [ form[8:-4].split('_')[0] for form in data.xpath('.//p[3]/img/@src')] + if 'epub' in formats: + formats.remove('epub') + formats.append('WOBLINK') if 'E Ink' in data.xpath('.//div[@class="prices"]/img/@title'): - formats += ', EPUB' + formats.insert(0, 'EPUB') counter -= 1 @@ -74,9 +78,9 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): s.cover_url = 'http://woblink.com' + cover_url s.title = title.strip() s.author = author.strip() - s.price = price + s.price = price + ' zł' s.detail_item = id.strip() - s.drm = SearchResult.DRM_LOCKED - s.formats = formats + s.drm = SearchResult.DRM_UNKNOWN if 'MOBI' in formats else SearchResult.DRM_LOCKED + s.formats = ', '.join(formats) yield s From 33d00175e03448c44e7eed85ab868016bab3d033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Wed, 21 Mar 2012 23:15:12 +0100 Subject: [PATCH 2/2] fix 'pdf' casing in the list --- src/calibre/gui2/store/stores/woblink_plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/gui2/store/stores/woblink_plugin.py b/src/calibre/gui2/store/stores/woblink_plugin.py index 022f48b95e..e9696b39a6 100644 --- a/src/calibre/gui2/store/stores/woblink_plugin.py +++ b/src/calibre/gui2/store/stores/woblink_plugin.py @@ -71,6 +71,8 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): formats.append('WOBLINK') if 'E Ink' in data.xpath('.//div[@class="prices"]/img/@title'): formats.insert(0, 'EPUB') + if 'pdf' in formats: + formats[formats.index('pdf')] = 'PDF' counter -= 1