summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2022-04-15 14:31:19 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2022-04-16 09:27:34 +0200
commit1a82e79b5018b578d984bebf667643b9e334a034 (patch)
tree4a8a07729fd505932097621fec985e00ed7384a6 /searx
parent3bb62823ec3af0e67bd2d959bec20c4791ee3bac (diff)
downloadsearxng-1a82e79b5018b578d984bebf667643b9e334a034.tar.gz
searxng-1a82e79b5018b578d984bebf667643b9e334a034.zip
dailymotion: send valid value for the language parameter
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/dailymotion.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/searx/engines/dailymotion.py b/searx/engines/dailymotion.py
index 5dc0d9dbe..f19bd934b 100644
--- a/searx/engines/dailymotion.py
+++ b/searx/engines/dailymotion.py
@@ -68,6 +68,13 @@ iframe_src = "https://www.dailymotion.com/embed/video/{video_id}"
# The request query filters by 'languages' & 'country', therefore instead of
# fetching only languages we need to fetch locales.
supported_languages_url = 'https://api.dailymotion.com/locales'
+supported_languages_iso639: Set[str] = set()
+
+
+def init(_engine_settings):
+ global supported_languages_iso639
+ supported_languages_iso639 = set([language.split('_')[0] for language in supported_languages])
+
def request(query, params):
@@ -79,9 +86,13 @@ def request(query, params):
language = 'en-US'
locale = babel.Locale.parse(language, sep='-')
+ language_iso639 = locale.language
+ if locale.language not in supported_languages_iso639:
+ language_iso639 = 'en'
+
query_args = {
'search': query,
- 'languages': locale.language,
+ 'languages': language_iso639,
'page': params['pageno'],
}