diff options
author | marc <a01200356@itesm.mx> | 2017-03-01 17:11:51 -0600 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2017-03-18 23:44:21 +0100 |
commit | fd65c1292179fb082e965a1ee6a88b9298a54fc1 (patch) | |
tree | bd2cc7302a1b7d81f2294aab1ad1de0aedd0bdd8 /searx/engines | |
parent | 805fb02ed1fb7f8e006c8def7d76a0d1958364bf (diff) | |
download | searxng-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/engines')
-rw-r--r-- | searx/engines/bing.py | 2 | ||||
-rw-r--r-- | searx/engines/qwant.py | 4 | ||||
-rw-r--r-- | searx/engines/swisscows.py | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/searx/engines/bing.py b/searx/engines/bing.py index 15c8ee611..4e7ead82d 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -94,6 +94,8 @@ def _fetch_supported_languages(resp): options = dom.xpath('//div[@id="limit-languages"]//input') for option in options: code = option.xpath('./@id')[0].replace('_', '-') + if code == 'nb': + code = 'no' supported_languages.append(code) return supported_languages diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 56282fdba..1fc4630fa 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -47,6 +47,8 @@ def request(query, params): # add language tag if specified if params['language'] != 'all': + if params['language'] == 'no' or params['language'].startswith('no-'): + params['language'] = params['language'].replace('no', 'nb', 1) if params['language'].find('-') < 0: # tries to get a country code from language for lang in supported_languages: @@ -118,6 +120,8 @@ def _fetch_supported_languages(resp): supported_languages = [] for lang in regions_json['languages'].values(): + if lang['code'] == 'nb': + lang['code'] = 'no' for country in lang['countries']: supported_languages.append(lang['code'] + '-' + country) diff --git a/searx/engines/swisscows.py b/searx/engines/swisscows.py index d8a454039..dd398857f 100644 --- a/searx/engines/swisscows.py +++ b/searx/engines/swisscows.py @@ -120,6 +120,8 @@ def _fetch_supported_languages(resp): options = dom.xpath('//div[@id="regions-popup"]//ul/li/a') for option in options: code = option.xpath('./@data-val')[0] + if code.startswith('nb-'): + code = code.replace('nb', 'no', 1) supported_languages.append(code) return supported_languages |