1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-22 12:10:11 +01:00

dailymotion: send valid value for the language parameter

This commit is contained in:
Alexandre Flament 2022-04-15 14:31:19 +02:00 committed by Markus Heiser
parent 3bb62823ec
commit 1a82e79b50

View File

@ -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'],
}