Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] set language_support for engines with languages in traits (#6258)

Markus Heisercf1410af8d79
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index b225575e7..6713aebd1 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -21,7 +21,7 @@ import msgspec
from searx import logger, settings
from searx.utils import load_module
-
+from searx.data import ENGINE_TRAITS
from searx.enginelib import Engine, EngineAbout
logger = logger.getChild('engines')
@@ -196,7 +196,7 @@ def update_engine_attributes(engine: "Engine | types.ModuleType", engine_data: d
engine.about = EngineAbout(**kvargs)
except TypeError as exc:
raise TypeError(
- f"engine {engine_data['name']} ({engine_data['engine']}) - in the about section --> {exc}"
+ f"engine '{engine_data['name']}' ({engine_data['engine']}) - in the about section --> {exc}"
) from exc
for param_name, param_value in engine_data.items():
@@ -214,6 +214,9 @@ def update_engine_attributes(engine: "Engine | types.ModuleType", engine_data: d
if not hasattr(engine, arg_name):
setattr(engine, arg_name, copy.deepcopy(arg_value))
+ if ENGINE_TRAITS.get(engine.name, {}).get("languages") and not engine.language_support:
+ raise ValueError(f"engine '{engine.name}' ({engine_data['engine']}) language_support should be set to True")
+
def update_attributes_for_tor(engine: "Engine | types.ModuleType"):
if using_tor_proxy(engine) and hasattr(engine, 'onion_url'):
diff --git a/searx/engines/annas_archive.py b/searx/engines/annas_archive.py
index e505cc074..c4676cc31 100644
--- a/searx/engines/annas_archive.py
+++ b/searx/engines/annas_archive.py
@@ -64,6 +64,7 @@ about: dict[str, t.Any] = {
# engine dependent config
categories = ["files", "books"]
paging: bool = True
+language_support = True
# search-url
base_url: list[str] | str = []
diff --git a/searx/engines/archlinux.py b/searx/engines/archlinux.py
index 4ccc6ab48..04787b5aa 100644
--- a/searx/engines/archlinux.py
+++ b/searx/engines/archlinux.py
@@ -35,6 +35,7 @@ about = {
categories = ["it", "software wikis"]
paging = True
main_wiki = "wiki.archlinux.org"
+language_support = True
def request(query, params):
diff --git a/searx/engines/boardreader.py b/searx/engines/boardreader.py
index f90d777d9..9b56295b3 100644
--- a/searx/engines/boardreader.py
+++ b/searx/engines/boardreader.py
@@ -34,6 +34,7 @@ about = {
categories = ["general", "social media"]
paging = True
time_range_support = True
+language_support = True
base_url = "https://boardreader.com"
time_range_map = {"day": "1", "week": "7", "month": "30", "year": "365"}
diff --git a/searx/engines/dailymotion.py b/searx/engines/dailymotion.py
index ff2e07c9b..fd5309b23 100644
--- a/searx/engines/dailymotion.py
+++ b/searx/engines/dailymotion.py
@@ -40,6 +40,7 @@ categories = ["videos"]
paging = True
page_size = 10
+language_support = True
time_range_support = True
time_delta_dict = {
"day": timedelta(days=1),
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py
index 4dd7f82bd..e2801d7e6 100644
--- a/searx/engines/duckduckgo.py
+++ b/searx/engines/duckduckgo.py
@@ -203,6 +203,7 @@ about: dict[str, str | bool] = {
categories: list[str] = ["general", "web"]
paging: bool = True
time_range_support: bool = True
+language_support = True
safesearch: bool = True
"""DDG-lite: user can't select but the results are filtered."""
diff --git a/searx/engines/duckduckgo_extra.py b/searx/engines/duckduckgo_extra.py
index 3cb12d0e3..3ea140161 100644
--- a/searx/engines/duckduckgo_extra.py
+++ b/searx/engines/duckduckgo_extra.py
@@ -28,6 +28,7 @@ about = {
"require_api_key": False,
"results": "JSON (site requires js to get images)",
}
+language_support = True
# engine dependent config
categories = []
diff --git a/searx/engines/duckduckgo_weather.py b/searx/engines/duckduckgo_weather.py
index f6d97a15b..070d09d85 100644
--- a/searx/engines/duckduckgo_weather.py
+++ b/searx/engines/duckduckgo_weather.py
@@ -26,6 +26,7 @@ about = {
"require_api_key": False,
"results": "JSON",
}
+language_support = True
# engine dependent config
categories = ["weather"]
diff --git a/searx/engines/google.py b/searx/engines/google.py
index e0048222b..ee31c3835 100644
--- a/searx/engines/google.py
+++ b/searx/engines/google.py
@@ -57,6 +57,7 @@ max_page = 50
.. _Google max 50 pages: https://github.com/searxng/searxng/issues/2982
"""
time_range_support = True
+language_support = True
safesearch = True
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py
index 8fc36f853..aba88d49e 100644
--- a/searx/engines/google_images.py
+++ b/searx/engines/google_images.py
@@ -43,6 +43,7 @@ max_page = 50
"""
time_range_support = True
+language_support = True
safesearch = True
filter_mapping = {0: 'images', 1: 'active', 2: 'active'}
diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py
index f8bc1d4fc..3971bc03a 100644
--- a/searx/engines/google_news.py
+++ b/searx/engines/google_news.py
@@ -66,6 +66,7 @@ about = {
categories = ["news"]
paging = False
time_range_support = False
+language_support = True
# Google-News results are always *SafeSearch*. Option 'safesearch' is set to
# False here.
diff --git a/searx/engines/mojeek.py b/searx/engines/mojeek.py
index 58951c54a..fbfe5ba0a 100644
--- a/searx/engines/mojeek.py
+++ b/searx/engines/mojeek.py
@@ -20,6 +20,7 @@ about = {
}
paging = True # paging is only supported for general search
safesearch = True
+language_support = True
time_range_support = True # time range search is supported for general and news
max_page = 10
diff --git a/searx/engines/odysee.py b/searx/engines/odysee.py
index 5b5292dc8..1e2a61f75 100644
--- a/searx/engines/odysee.py
+++ b/searx/engines/odysee.py
@@ -26,6 +26,7 @@ about = {
# Engine configuration
paging = True
time_range_support = True
+language_support = True
results_per_page = 20
categories = ["videos"]
diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py
index ee2b1ce28..617527c1e 100644
--- a/searx/engines/peertube.py
+++ b/searx/engines/peertube.py
@@ -25,6 +25,7 @@ about = {
"require_api_key": False,
"results": "JSON",
}
+language_support = True
# engine dependent config
categories = ["videos"]
diff --git a/searx/engines/radio_browser.py b/searx/engines/radio_browser.py
index d79963c2e..812bc8ef4 100644
--- a/searx/engines/radio_browser.py
+++ b/searx/engines/radio_browser.py
@@ -26,6 +26,7 @@ about = {
"require_api_key": False,
"results": "JSON",
}
+language_support = True
paging = True
categories = ["music", "radio"]
diff --git a/searx/engines/sepiasearch.py b/searx/engines/sepiasearch.py
index 60ff2e6be..3d4d2f130 100644
--- a/searx/engines/sepiasearch.py
+++ b/searx/engines/sepiasearch.py
@@ -25,6 +25,7 @@ about = {
"require_api_key": False,
"results": 'JSON',
}
+language_support = True
# engine dependent config
categories = ['videos']
diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py
index f5a1a1381..b04d1e25b 100644
--- a/searx/engines/startpage.py
+++ b/searx/engines/startpage.py
@@ -131,6 +131,7 @@ max_page = 18
"""Tested 18 pages maximum (argument ``page``), to be save max is set to 20."""
time_range_support = True
+language_support = True
safesearch = True
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py
index 85f747d93..ffb5dc136 100644
--- a/searx/engines/wikidata.py
+++ b/searx/engines/wikidata.py
@@ -40,6 +40,7 @@ about = {
"require_api_key": False,
"results": 'JSON',
}
+language_support = True
display_type = ["infobox"]
"""A list of display types composed from ``infobox`` and ``list``. The latter
diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py
index b35cde866..1b41240ee 100644
--- a/searx/engines/wikipedia.py
+++ b/searx/engines/wikipedia.py
@@ -72,6 +72,7 @@ about = {
"require_api_key": False,
"results": "JSON",
}
+language_support = True
display_type = ["infobox"]
"""A list of display types composed from ``infobox`` and ``list``. The latter
diff --git a/searx/engines/yep.py b/searx/engines/yep.py
index 3b6d9aee5..e87a1bef2 100644
--- a/searx/engines/yep.py
+++ b/searx/engines/yep.py
@@ -22,6 +22,7 @@ about = {
"require_api_key": False,
"results": "JSON",
}
+language_support = True
base_url = "https://api.yep.com"
web_base_url = "https://yep.com"
diff --git a/searx/engines/zlibrary.py b/searx/engines/zlibrary.py
index 9f0f7d88e..4b1dac7a5 100644
--- a/searx/engines/zlibrary.py
+++ b/searx/engines/zlibrary.py
@@ -61,6 +61,7 @@ about: dict[str, t.Any] = {
categories: list[str] = ["files", "books"]
paging: bool = True
+language_support = True
base_url: str = "https://zlibrary-global.se"
zlib_year_from: str = ""