From 60d606910dd24dec238e80fe8359527693b72dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Tue, 27 Mar 2012 21:34:20 +0200 Subject: [PATCH] formats section rewritten --- .../gui2/store/stores/woblink_plugin.py | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/calibre/gui2/store/stores/woblink_plugin.py b/src/calibre/gui2/store/stores/woblink_plugin.py index 9f514bfe19..4f47ca9a07 100644 --- a/src/calibre/gui2/store/stores/woblink_plugin.py +++ b/src/calibre/gui2/store/stores/woblink_plugin.py @@ -9,6 +9,7 @@ __docformat__ = 'restructuredtext en' import re import urllib from contextlib import closing +import copy from lxml import html @@ -66,13 +67,6 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): price = ''.join(data.xpath('.//div[@class="prices"]/span[1]/span/text()')) price = re.sub('\.', ',', price) 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.insert(0, 'EPUB') - if 'pdf' in formats: - formats[formats.index('pdf')] = 'PDF' s = SearchResult() s.cover_url = 'http://woblink.com' + cover_url @@ -83,12 +77,8 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): # MOBI should be send first, if 'MOBI' in formats: - t = SearchResult() - t.cover_url = s.cover_url - t.title = s.title +' MOBI' - t.author = s.author - t.price = s.price - t.detail_item = s.detail_item + t = copy.copy(s) + t.title += ' MOBI' t.drm = SearchResult.DRM_UNLOCKED t.formats = 'MOBI' formats.remove('MOBI') @@ -98,15 +88,14 @@ class WoblinkStore(BasicStoreConfig, StorePlugin): # and the remaining formats (if any) next if formats: - s = SearchResult() - s.cover_url = 'http://woblink.com' + cover_url - s.title = title.strip() - s.author = author.strip() - s.price = price + ' zł' - s.detail_item = id.strip() + 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') s.drm = SearchResult.DRM_LOCKED - s.formats = ', '.join(formats) + s.formats = ', '.join(formats).upper() counter -= 1 yield s