From 1cf191137dceddb182d5a7914845fb1a9502e535 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 4 Jul 2011 13:39:51 -0400 Subject: [PATCH 1/4] Store: clean filenames of downloaded books. --- src/calibre/gui2/store/search/search.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/gui2/store/search/search.py b/src/calibre/gui2/store/search/search.py index f6fa423e23..9e78f75b4a 100644 --- a/src/calibre/gui2/store/search/search.py +++ b/src/calibre/gui2/store/search/search.py @@ -22,6 +22,7 @@ from calibre.gui2.store.search.adv_search_builder import AdvSearchBuilderDialog from calibre.gui2.store.search.download_thread import SearchThreadPool, \ CacheUpdateThreadPool from calibre.gui2.store.search.search_ui import Ui_Dialog +from calibre.utils.filenames import ascii_filename class SearchDialog(QDialog, Ui_Dialog): @@ -350,6 +351,7 @@ class SearchDialog(QDialog, Ui_Dialog): if d.exec_() == d.Accepted: ext = d.format() fname = result.title + '.' + ext.lower() + fname = ascii_filename(fname) self.gui.download_ebook(result.downloads[ext], filename=fname) def open_store(self, result): From 00efad21a3c9d94401795ec8c5d092494359f0fa Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 4 Jul 2011 15:07:49 -0400 Subject: [PATCH 2/4] Store: improve price compare. --- src/calibre/gui2/store/search/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/gui2/store/search/models.py b/src/calibre/gui2/store/search/models.py index 1fb0e5327b..9028acb142 100644 --- a/src/calibre/gui2/store/search/models.py +++ b/src/calibre/gui2/store/search/models.py @@ -22,6 +22,7 @@ from calibre.utils.icu import sort_key from calibre.utils.search_query_parser import SearchQueryParser def comparable_price(text): + text = re.sub(r'[^0-9.,]', '', text) if len(text) < 3 or text[-3] not in ('.', ','): text += '00' text = re.sub(r'\D', '', text) From ae3894de1e967b659ef92e04c89f714f8a192958 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 4 Jul 2011 15:14:29 -0400 Subject: [PATCH 3/4] Store: Ignore whitespace before and after search location. --- src/calibre/gui2/store/search/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/gui2/store/search/models.py b/src/calibre/gui2/store/search/models.py index 9028acb142..1a2327fc45 100644 --- a/src/calibre/gui2/store/search/models.py +++ b/src/calibre/gui2/store/search/models.py @@ -294,6 +294,7 @@ class SearchFilter(SearchQueryParser): return self.srs def get_matches(self, location, query): + query = query.strip() location = location.lower().strip() if location == 'authors': location = 'author' From 123a8b1c1e1016acb741b6a7d55fa8b94853592b Mon Sep 17 00:00:00 2001 From: John Schember Date: Tue, 5 Jul 2011 16:27:02 -0400 Subject: [PATCH 4/4] Store: Fix price for Smashwords store. --- src/calibre/gui2/store/stores/smashwords_plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/store/stores/smashwords_plugin.py b/src/calibre/gui2/store/stores/smashwords_plugin.py index 73700ed546..7a7e756a05 100644 --- a/src/calibre/gui2/store/stores/smashwords_plugin.py +++ b/src/calibre/gui2/store/stores/smashwords_plugin.py @@ -77,9 +77,12 @@ class SmashwordsStore(BasicStoreConfig, StorePlugin): title = ''.join(data.xpath('//a[@class="bookTitle"]/text()')) subnote = ''.join(data.xpath('//span[@class="subnote"]/text()')) author = ''.join(data.xpath('//span[@class="subnote"]/a/text()')) - price = subnote.partition('$')[2] - price = price.split(u'\xa0')[0] - price = '$' + price + if '$' in subnote: + price = subnote.partition('$')[2] + price = price.split(u'\xa0')[0] + price = '$' + price + else: + price = '$0.00' counter -= 1