From ea9d979cc33c875dbc3439f8ef7b7f1eec7bb0b4 Mon Sep 17 00:00:00 2001 From: Marc Abonce Seguin Date: Mon, 14 Sep 2020 00:05:48 -0700 Subject: [PATCH] add language names in qwant's fetch languages function --- searx/engines/__init__.py | 2 +- searx/engines/qwant.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 9fcf812b..5b91c08c 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -24,9 +24,9 @@ from babel.localedata import locale_identifiers from flask_babel import gettext from operator import itemgetter from json import loads -from requests import get from searx import settings from searx import logger +from searx.poolrequests import get from searx.utils import load_module, match_language, get_engine_from_settings diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index ac918b90..98460604 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -124,11 +124,10 @@ def _fetch_supported_languages(resp): regions_json = loads(response_text) - supported_languages = [] + 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) + lang_code = "{lang}-{country}".format(lang=lang['code'], country=country) + supported_languages[lang_code] = {'name': lang['name']} return supported_languages