logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 350a84520d9da2499ffd5b0fbe6218692f2a330d
parent: 3a8d193d1f746165df35e573f18c7abee970feb0
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Tue, 26 Jul 2016 00:22:05 +0200

[fix] time range detection

Diffstat:

searx/engines/deviantart.py | 3+--
searx/engines/duckduckgo.py | 2+-
searx/engines/google.py | 2+-
searx/engines/google_images.py | 3+--
searx/engines/yahoo.py | 2+-
tests/unit/engines/test_deviantart.py | 1+
tests/unit/engines/test_duckduckgo.py | 1+
tests/unit/engines/test_google.py | 1+
tests/unit/engines/test_google_images.py | 1+
tests/unit/engines/test_yahoo.py | 1+
10 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/searx/engines/deviantart.py b/searx/engines/deviantart.py @@ -13,7 +13,6 @@ """ from urllib import urlencode -from urlparse import urljoin from lxml import html import re from searx.engines.xpath import extract_text @@ -39,7 +38,7 @@ def request(query, params): params['url'] = search_url.format(offset=offset, query=urlencode({'q': query})) - if params['time_range']: + if params['time_range'] in time_range_dict: params['url'] += time_range_url.format(range=time_range_dict[params['time_range']]) return params diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py @@ -67,7 +67,7 @@ def request(query, params): params['url'] = url.format( query=urlencode({'q': query}), offset=offset) - if params['time_range']: + if params['time_range'] in time_range_dict: params['url'] += time_range_url.format(range=time_range_dict[params['time_range']]) return params diff --git a/searx/engines/google.py b/searx/engines/google.py @@ -185,7 +185,7 @@ def request(query, params): query=urlencode({'q': query}), hostname=google_hostname, lang=url_lang) - if params['time_range']: + if params['time_range'] in time_range_dict: params['url'] += time_range_search.format(range=time_range_dict[params['time_range']]) params['headers']['Accept-Language'] = language diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py @@ -11,7 +11,6 @@ """ from urllib import urlencode -from urlparse import parse_qs from json import loads from lxml import html @@ -39,7 +38,7 @@ def request(query, params): params['url'] = search_url.format(query=urlencode({'q': query}), offset=offset, safesearch=safesearch) - if params['time_range']: + if params['time_range'] in time_range_dict: params['url'] += time_range_search.format(range=time_range_dict[params['time_range']]) if safesearch and params['safesearch']: diff --git a/searx/engines/yahoo.py b/searx/engines/yahoo.py @@ -58,7 +58,7 @@ def parse_url(url_string): def _get_url(query, offset, language, time_range): - if time_range: + if time_range in time_range_dict: return base_url + search_url_with_time.format(offset=offset, query=urlencode({'p': query}), lang=language, diff --git a/tests/unit/engines/test_deviantart.py b/tests/unit/engines/test_deviantart.py @@ -10,6 +10,7 @@ class TestDeviantartEngine(SearxTestCase): query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 0 + dicto['time_range'] = '' params = deviantart.request(query, dicto) self.assertTrue('url' in params) self.assertTrue(query in params['url']) diff --git a/tests/unit/engines/test_duckduckgo.py b/tests/unit/engines/test_duckduckgo.py @@ -12,6 +12,7 @@ class TestDuckduckgoEngine(SearxTestCase): dicto = defaultdict(dict) dicto['pageno'] = 1 dicto['language'] = 'de_CH' + dicto['time_range'] = '' params = duckduckgo.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) diff --git a/tests/unit/engines/test_google.py b/tests/unit/engines/test_google.py @@ -19,6 +19,7 @@ class TestGoogleEngine(SearxTestCase): dicto = defaultdict(dict) dicto['pageno'] = 1 dicto['language'] = 'fr_FR' + dicto['time_range'] = '' params = google.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) diff --git a/tests/unit/engines/test_google_images.py b/tests/unit/engines/test_google_images.py @@ -11,6 +11,7 @@ class TestGoogleImagesEngine(SearxTestCase): dicto = defaultdict(dict) dicto['pageno'] = 1 dicto['safesearch'] = 1 + dicto['time_range'] = '' params = google_images.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) diff --git a/tests/unit/engines/test_yahoo.py b/tests/unit/engines/test_yahoo.py @@ -28,6 +28,7 @@ class TestYahooEngine(SearxTestCase): query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 + dicto['time_range'] = '' dicto['language'] = 'fr_FR' params = yahoo.request(query, dicto) self.assertIn('url', params)