summaryrefslogtreecommitdiff
path: root/searx/search.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2017-03-01 17:11:51 -0600
committerAdam Tauber <asciimoo@gmail.com>2017-03-18 23:44:21 +0100
commitfd65c1292179fb082e965a1ee6a88b9298a54fc1 (patch)
treebd2cc7302a1b7d81f2294aab1ad1de0aedd0bdd8 /searx/search.py
parent805fb02ed1fb7f8e006c8def7d76a0d1958364bf (diff)
downloadsearxng-fd65c1292179fb082e965a1ee6a88b9298a54fc1.tar.gz
searxng-fd65c1292179fb082e965a1ee6a88b9298a54fc1.zip
make search language handling less strict
languages.py can change, so users may query on a language that is not on the list anymore, even if it is still recognized by a few engines. also made no and nb the same because they seem to return the same, though most engines will only support one or the other.
Diffstat (limited to 'searx/search.py')
-rw-r--r--searx/search.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/searx/search.py b/searx/search.py
index 9425ca578..980cfeb99 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -27,20 +27,16 @@ from searx.engines import (
)
from searx.answerers import ask
from searx.utils import gen_useragent
-from searx.query import RawTextQuery, SearchQuery
+from searx.query import RawTextQuery, SearchQuery, VALID_LANGUAGE_CODE
from searx.results import ResultContainer
from searx import logger
from searx.plugins import plugins
-from searx.languages import language_codes
from searx.exceptions import SearxParameterException
logger = logger.getChild('search')
number_of_searches = 0
-language_code_set = set(l[0].lower() for l in language_codes)
-language_code_set.add('all')
-
def send_http_request(engine, request_params, start_time, timeout_limit):
# for page_load_time stats
@@ -219,7 +215,7 @@ def get_search_query_from_webapp(preferences, form):
query_lang = preferences.get_value('language')
# check language
- if query_lang.lower() not in language_code_set:
+ if not VALID_LANGUAGE_CODE.match(query_lang):
raise SearxParameterException('language', query_lang)
# get safesearch
@@ -371,11 +367,6 @@ class Search(object):
if search_query.pageno > 1 and not engine.paging:
continue
- # if search-language is set and engine does not
- # provide language-support, skip
- if search_query.lang != 'all' and not engine.language_support:
- continue
-
# if time_range is not supported, skip
if search_query.time_range and not engine.time_range_support:
continue