diff --git a/src/calibre/gui2/store/bn_plugin.py b/src/calibre/gui2/store/bn_plugin.py index f26a60c89d..62826e825d 100644 --- a/src/calibre/gui2/store/bn_plugin.py +++ b/src/calibre/gui2/store/bn_plugin.py @@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en' import random import re -import urllib2 +import urllib from contextlib import closing from lxml import html @@ -48,7 +48,7 @@ class BNStore(BasicStoreConfig, StorePlugin): def search(self, query, max_results=10, timeout=60): url = 'http://productsearch.barnesandnoble.com/search/results.aspx?STORE=EBOOK&SZE=%s&WRD=' % max_results - url += urllib2.quote(query) + url += urllib.quote_plus(query) br = browser() diff --git a/src/calibre/gui2/store/search/download_thread.py b/src/calibre/gui2/store/search/download_thread.py index 6dd59cc5a7..97279d7773 100644 --- a/src/calibre/gui2/store/search/download_thread.py +++ b/src/calibre/gui2/store/search/download_thread.py @@ -12,6 +12,7 @@ from threading import Thread from Queue import Queue from calibre import browser +from calibre.constants import DEBUG from calibre.utils.magick.draw import thumbnail class GenericDownloadThreadPool(object): @@ -119,7 +120,8 @@ class SearchThread(Thread): self.results.put((res, store_plugin)) self.tasks.task_done() except: - traceback.print_exc() + if DEBUG: + traceback.print_exc() class CoverThreadPool(GenericDownloadThreadPool): @@ -157,7 +159,8 @@ class CoverThread(Thread): callback() self.tasks.task_done() except: - continue + if DEBUG: + traceback.print_exc() class DetailsThreadPool(GenericDownloadThreadPool): @@ -191,7 +194,8 @@ class DetailsThread(Thread): callback(result) self.tasks.task_done() except: - continue + if DEBUG: + traceback.print_exc() class CacheUpdateThreadPool(GenericDownloadThreadPool): @@ -221,4 +225,5 @@ class CacheUpdateThread(Thread): store_plugin, timeout = self.tasks.get() store_plugin.update_cache(timeout=timeout, suppress_progress=True) except: - traceback.print_exc() + if DEBUG: + traceback.print_exc() diff --git a/src/calibre/gui2/store/search/search.py b/src/calibre/gui2/store/search/search.py index f7e8c88cd9..eea1a692de 100644 --- a/src/calibre/gui2/store/search/search.py +++ b/src/calibre/gui2/store/search/search.py @@ -139,14 +139,17 @@ class SearchDialog(QDialog, Ui_Dialog): query = query.replace('>', '') query = query.replace('<', '') # Remove the prefix. - for loc in ( 'all', 'author', 'authors', 'title'): - query = re.sub(r'%s:"?(?P[^\s"]+)"?' % loc, '\g', query) + for loc in ('all', 'author', 'authors', 'title'): + query = re.sub(r'%s:"(?P[^\s"]+)"' % loc, '\g', query) + query = query.replace('%s:' % loc, '') # Remove the prefix and search text. for loc in ('cover', 'drm', 'format', 'formats', 'price', 'store'): query = re.sub(r'%s:"[^"]"' % loc, '', query) query = re.sub(r'%s:[^\s]*' % loc, '', query) # Remove logic. - query = re.sub(r'(^|\s)(and|not|or)(\s|$)', ' ', query) + query = re.sub(r'(^|\s)(and|not|or|a|the|is|of)(\s|$)', ' ', query) + # Remove " + query = query.replace('"', '') # Remove excess whitespace. query = re.sub(r'\s{2,}', ' ', query) query = query.strip()