From ca93a018444041f64c193b4e623b9d6d1150b042 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sun, 24 Jan 2021 09:58:57 +0100 Subject: [PATCH] [mod] dynamically set language_support variable The language_support variable is set to True by default, and set to False in only 5 engines. Except the documentation and the /config URL, this variable is not used. This commit remove the variable definition in the engines, and set value according to supported_languages length: False when the length is 0, True otherwise. Close #2485 --- docs/dev/engine_overview.rst | 2 -- searx/engines/__init__.py | 4 +++- searx/engines/archlinux.py | 1 - searx/engines/bing.py | 1 - searx/engines/bing_images.py | 1 - searx/engines/bing_news.py | 1 - searx/engines/bing_videos.py | 1 - searx/engines/dailymotion.py | 1 - searx/engines/doku.py | 1 - searx/engines/duckduckgo.py | 1 - searx/engines/duckduckgo_images.py | 1 - searx/engines/duden.py | 1 - searx/engines/etools.py | 1 - searx/engines/genius.py | 1 - searx/engines/gentoo.py | 1 - searx/engines/gigablast.py | 1 - searx/engines/google.py | 1 - searx/engines/google_images.py | 1 - searx/engines/google_news.py | 1 - searx/engines/invidious.py | 1 - searx/engines/mediawiki.py | 1 - searx/engines/peertube.py | 1 - searx/engines/photon.py | 1 - searx/engines/qwant.py | 1 - searx/engines/sepiasearch.py | 1 - searx/engines/startpage.py | 1 - searx/engines/yacy.py | 1 - searx/engines/yahoo.py | 1 - searx/engines/yahoo_news.py | 1 - searx/engines/yandex.py | 1 - searx/engines/youtube_api.py | 1 - searx/engines/youtube_noapi.py | 1 - 32 files changed, 3 insertions(+), 33 deletions(-) diff --git a/docs/dev/engine_overview.rst b/docs/dev/engine_overview.rst index 0d2c00e87..7007e7b99 100644 --- a/docs/dev/engine_overview.rst +++ b/docs/dev/engine_overview.rst @@ -42,7 +42,6 @@ argument type information ======================= =========== ======================================================== categories list pages, in which the engine is working paging boolean support multible pages -language_support boolean support language choosing time_range_support boolean support search time range engine_type str ``online`` by default, other possibles values are ``offline``, ``online_dictionnary``, ``online_currency`` @@ -97,7 +96,6 @@ example code # engine dependent config categories = ['general'] paging = True - language_support = True making a request diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index f2b7c5a84..80d5d18fc 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -44,7 +44,6 @@ babel_langs = [lang_parts[0] + '-' + lang_parts[-1] if len(lang_parts) > 1 else engine_shortcuts = {} engine_default_args = {'paging': False, 'categories': ['general'], - 'language_support': True, 'supported_languages': [], 'safesearch': False, 'timeout': settings['outgoing']['request_timeout'], @@ -127,6 +126,9 @@ def load_engine(engine_data): setattr(engine, 'language_aliases', language_aliases) + # language_support + setattr(engine, 'language_support', len(getattr(engine, 'supported_languages', [])) > 0) + # assign language fetching method if auxiliary method exists if hasattr(engine, '_fetch_supported_languages'): setattr(engine, 'fetch_supported_languages', diff --git a/searx/engines/archlinux.py b/searx/engines/archlinux.py index d29d65ba3..aeac145d1 100644 --- a/searx/engines/archlinux.py +++ b/searx/engines/archlinux.py @@ -21,7 +21,6 @@ about = { # engine dependent config categories = ['it'] -language_support = True paging = True base_url = 'https://wiki.archlinux.org' diff --git a/searx/engines/bing.py b/searx/engines/bing.py index edf6baef9..f849cef92 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -24,7 +24,6 @@ about = { # engine dependent config categories = ['general'] paging = True -language_support = True supported_languages_url = 'https://www.bing.com/account/general' language_aliases = {'zh-CN': 'zh-CHS', 'zh-TW': 'zh-CHT', 'zh-HK': 'zh-CHT'} diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index b4ca57f4b..d65d505cd 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -26,7 +26,6 @@ categories = ['images'] paging = True safesearch = True time_range_support = True -language_support = True supported_languages_url = 'https://www.bing.com/account/general' number_of_results = 28 diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py index 2e4b78278..738c642aa 100644 --- a/searx/engines/bing_news.py +++ b/searx/engines/bing_news.py @@ -25,7 +25,6 @@ about = { # engine dependent config categories = ['news'] paging = True -language_support = True time_range_support = True # search-url diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py index b4584bb37..2e1f13de2 100644 --- a/searx/engines/bing_videos.py +++ b/searx/engines/bing_videos.py @@ -26,7 +26,6 @@ paging = True safesearch = True time_range_support = True number_of_results = 28 -language_support = True base_url = 'https://www.bing.com/' search_string = 'videos/search'\ diff --git a/searx/engines/dailymotion.py b/searx/engines/dailymotion.py index 874e0f42a..92d368c11 100644 --- a/searx/engines/dailymotion.py +++ b/searx/engines/dailymotion.py @@ -21,7 +21,6 @@ about = { # engine dependent config categories = ['videos'] paging = True -language_support = True # search-url # see http://www.dailymotion.com/doc/api/obj-video.html diff --git a/searx/engines/doku.py b/searx/engines/doku.py index ed1eab388..cf38b3b9a 100644 --- a/searx/engines/doku.py +++ b/searx/engines/doku.py @@ -20,7 +20,6 @@ about = { # engine dependent config categories = ['general'] # TODO , 'images', 'music', 'videos', 'files' paging = False -language_support = False number_of_results = 5 # search-url diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index fc20de239..7f1378264 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -20,7 +20,6 @@ about = { # engine dependent config categories = ['general'] paging = False -language_support = True supported_languages_url = 'https://duckduckgo.com/util/u172.js' time_range_support = True diff --git a/searx/engines/duckduckgo_images.py b/searx/engines/duckduckgo_images.py index b5c2d4506..305eb1ca1 100644 --- a/searx/engines/duckduckgo_images.py +++ b/searx/engines/duckduckgo_images.py @@ -26,7 +26,6 @@ about = { # engine dependent config categories = ['images'] paging = True -language_support = True safesearch = True # search-url diff --git a/searx/engines/duden.py b/searx/engines/duden.py index f1c9efd3f..57c76e970 100644 --- a/searx/engines/duden.py +++ b/searx/engines/duden.py @@ -20,7 +20,6 @@ about = { categories = ['general'] paging = True -language_support = False # search-url base_url = 'https://www.duden.de/' diff --git a/searx/engines/etools.py b/searx/engines/etools.py index 77d7e71c6..bf4f4ea1f 100644 --- a/searx/engines/etools.py +++ b/searx/engines/etools.py @@ -19,7 +19,6 @@ about = { categories = ['general'] paging = False -language_support = False safesearch = True base_url = 'https://www.etools.ch' diff --git a/searx/engines/genius.py b/searx/engines/genius.py index 1667d529d..9f6a8cd5f 100644 --- a/searx/engines/genius.py +++ b/searx/engines/genius.py @@ -20,7 +20,6 @@ about = { # engine dependent config categories = ['music'] paging = True -language_support = False page_size = 5 url = 'https://genius.com/api/' diff --git a/searx/engines/gentoo.py b/searx/engines/gentoo.py index 55f15576e..325e132a6 100644 --- a/searx/engines/gentoo.py +++ b/searx/engines/gentoo.py @@ -19,7 +19,6 @@ about = { # engine dependent config categories = ['it'] -language_support = True paging = True base_url = 'https://wiki.gentoo.org' diff --git a/searx/engines/gigablast.py b/searx/engines/gigablast.py index f5f89a736..248991df9 100644 --- a/searx/engines/gigablast.py +++ b/searx/engines/gigablast.py @@ -24,7 +24,6 @@ about = { categories = ['general'] # gigablast's pagination is totally damaged, don't use it paging = False -language_support = True safesearch = True # search-url diff --git a/searx/engines/google.py b/searx/engines/google.py index 138c90411..8c20029a3 100644 --- a/searx/engines/google.py +++ b/searx/engines/google.py @@ -31,7 +31,6 @@ about = { # engine dependent config categories = ['general'] paging = True -language_support = True time_range_support = True safesearch = True supported_languages_url = 'https://www.google.com/preferences?#languages' diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index 6ecbb9ab5..01bdbeef2 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -56,7 +56,6 @@ about = { # engine dependent config categories = ['images'] paging = False -language_support = True use_locale_domain = True time_range_support = True safesearch = True diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py index b10f77005..27eee8144 100644 --- a/searx/engines/google_news.py +++ b/searx/engines/google_news.py @@ -68,7 +68,6 @@ time_range_dict = { categories = ['news'] paging = False -language_support = True use_locale_domain = True time_range_support = True diff --git a/searx/engines/invidious.py b/searx/engines/invidious.py index 61a6e5a19..4fa80d128 100644 --- a/searx/engines/invidious.py +++ b/searx/engines/invidious.py @@ -21,7 +21,6 @@ about = { # engine dependent config categories = ["videos", "music"] paging = True -language_support = True time_range_support = True diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index 21abff86e..da4321250 100644 --- a/searx/engines/mediawiki.py +++ b/searx/engines/mediawiki.py @@ -19,7 +19,6 @@ about = { # engine dependent config categories = ['general'] -language_support = True paging = True number_of_results = 1 search_type = 'nearmatch' # possible values: title, text, nearmatch diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py index 549141079..b5b17c6f2 100644 --- a/searx/engines/peertube.py +++ b/searx/engines/peertube.py @@ -21,7 +21,6 @@ about = { # engine dependent config categories = ["videos"] paging = True -language_support = True base_url = "https://peer.tube/" supported_languages_url = base_url + "api/v1/videos/languages" diff --git a/searx/engines/photon.py b/searx/engines/photon.py index f12bcd22a..8c11c8ffb 100644 --- a/searx/engines/photon.py +++ b/searx/engines/photon.py @@ -20,7 +20,6 @@ about = { # engine dependent config categories = ['map'] paging = False -language_support = True number_of_results = 10 # search-url diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 87499c8ad..13dcf1250 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -23,7 +23,6 @@ about = { # engine dependent config categories = [] paging = True -language_support = True supported_languages_url = 'https://qwant.com/region' category_to_keyword = {'general': 'web', diff --git a/searx/engines/sepiasearch.py b/searx/engines/sepiasearch.py index 3433c897a..8ccde404f 100644 --- a/searx/engines/sepiasearch.py +++ b/searx/engines/sepiasearch.py @@ -20,7 +20,6 @@ about = { categories = ['videos'] paging = True -language_support = True time_range_support = True safesearch = True supported_languages = [ diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index 68157971d..e71310be6 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -29,7 +29,6 @@ categories = ['general'] # storing of qid's between mulitble search-calls paging = True -language_support = True supported_languages_url = 'https://www.startpage.com/do/settings' # search-url diff --git a/searx/engines/yacy.py b/searx/engines/yacy.py index afd59cd49..c194ca451 100644 --- a/searx/engines/yacy.py +++ b/searx/engines/yacy.py @@ -24,7 +24,6 @@ about = { # engine dependent config categories = ['general', 'images'] # TODO , 'music', 'videos', 'files' paging = True -language_support = True number_of_results = 5 http_digest_auth_user = "" http_digest_auth_pass = "" diff --git a/searx/engines/yahoo.py b/searx/engines/yahoo.py index eb07a45fc..26a4469b9 100644 --- a/searx/engines/yahoo.py +++ b/searx/engines/yahoo.py @@ -20,7 +20,6 @@ about = { # engine dependent config categories = ['general'] paging = True -language_support = True time_range_support = True # search-url diff --git a/searx/engines/yahoo_news.py b/searx/engines/yahoo_news.py index b324ecdf3..ca17896dc 100644 --- a/searx/engines/yahoo_news.py +++ b/searx/engines/yahoo_news.py @@ -25,7 +25,6 @@ about = { # engine dependent config categories = ['news'] paging = True -language_support = True # search-url search_url = 'https://news.search.yahoo.com/search?{query}&b={offset}&{lang}=uh3_news_web_gs_1&pz=10&xargs=0&vl=lang_{lang}' # noqa diff --git a/searx/engines/yandex.py b/searx/engines/yandex.py index 57a2f4b79..ff946cc46 100644 --- a/searx/engines/yandex.py +++ b/searx/engines/yandex.py @@ -23,7 +23,6 @@ about = { # engine dependent config categories = ['general'] paging = True -language_support = True # TODO default_tld = 'com' language_map = {'ru': 'ru', diff --git a/searx/engines/youtube_api.py b/searx/engines/youtube_api.py index b3dcb4907..ed27db07b 100644 --- a/searx/engines/youtube_api.py +++ b/searx/engines/youtube_api.py @@ -21,7 +21,6 @@ about = { # engine dependent config categories = ['videos', 'music'] paging = False -language_support = True api_key = None # search-url diff --git a/searx/engines/youtube_noapi.py b/searx/engines/youtube_noapi.py index 4a6df57c4..90b93f0a4 100644 --- a/searx/engines/youtube_noapi.py +++ b/searx/engines/youtube_noapi.py @@ -20,7 +20,6 @@ about = { # engine dependent config categories = ['videos', 'music'] paging = True -language_support = False time_range_support = True # search-url