summaryrefslogtreecommitdiff
path: root/searx/engines/dailymotion.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-06-25 12:37:31 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-06-25 13:58:26 +0200
commite8706fb738da9feb21e596f403dddb40e69c8a7b (patch)
tree1ddf3dbd2860d65de879d9feecf7df01a7727680 /searx/engines/dailymotion.py
parent2e4a435134e0f677fbe24853dd81453a54770674 (diff)
downloadsearxng-e8706fb738da9feb21e596f403dddb40e69c8a7b.tar.gz
searxng-e8706fb738da9feb21e596f403dddb40e69c8a7b.zip
[fix] engine & network issues / documentation and type annotations
This patch fixes some quirks and issues related to the engines and the network. Each engine has its own network and this network was broken for the following engines[1]: - archlinux - bing - dailymotion - duckduckgo - google - peertube - startpage - wikipedia Since the files have been touched anyway, the type annotaions of the engine modules has also been completed so that error messages from the type checker are no longer reported. Related and (partial) fixed issue: - [1] https://github.com/searxng/searxng/issues/762#issuecomment-1605323861 - [2] https://github.com/searxng/searxng/issues/2513 - [3] https://github.com/searxng/searxng/issues/2515 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/dailymotion.py')
-rw-r--r--searx/engines/dailymotion.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/searx/engines/dailymotion.py b/searx/engines/dailymotion.py
index d734ec3c8..99da9616c 100644
--- a/searx/engines/dailymotion.py
+++ b/searx/engines/dailymotion.py
@@ -18,9 +18,9 @@ from urllib.parse import urlencode
import time
import babel
-from searx.exceptions import SearxEngineAPIException
-from searx import network
+from searx.network import get, raise_for_httperror # see https://github.com/searxng/searxng/issues/762
from searx.utils import html_to_text
+from searx.exceptions import SearxEngineAPIException
from searx.locales import region_tag, language_tag
from searx.enginelib.traits import EngineTraits
@@ -106,7 +106,7 @@ def request(query, params):
if not query:
return False
- eng_region = traits.get_region(params['searxng_locale'], 'en_US')
+ eng_region: str = traits.get_region(params['searxng_locale'], 'en_US') # type: ignore
eng_lang = traits.get_language(params['searxng_locale'], 'en')
args = {
@@ -156,7 +156,7 @@ def response(resp):
if 'error' in search_res:
raise SearxEngineAPIException(search_res['error'].get('message'))
- network.raise_for_httperror(resp)
+ raise_for_httperror(resp)
# parse results
for res in search_res.get('list', []):
@@ -218,11 +218,11 @@ def fetch_traits(engine_traits: EngineTraits):
"""
- resp = network.get('https://api.dailymotion.com/locales')
- if not resp.ok:
+ resp = get('https://api.dailymotion.com/locales')
+ if not resp.ok: # type: ignore
print("ERROR: response from dailymotion/locales is not OK.")
- for item in resp.json()['list']:
+ for item in resp.json()['list']: # type: ignore
eng_tag = item['locale']
if eng_tag in ('en_EN', 'ar_AA'):
continue
@@ -241,11 +241,11 @@ def fetch_traits(engine_traits: EngineTraits):
locale_lang_list = [x.split('_')[0] for x in engine_traits.regions.values()]
- resp = network.get('https://api.dailymotion.com/languages')
- if not resp.ok:
+ resp = get('https://api.dailymotion.com/languages')
+ if not resp.ok: # type: ignore
print("ERROR: response from dailymotion/languages is not OK.")
- for item in resp.json()['list']:
+ for item in resp.json()['list']: # type: ignore
eng_tag = item['code']
if eng_tag in locale_lang_list:
sxng_tag = language_tag(babel.Locale.parse(eng_tag))