2 Commits

Author SHA1 Message Date
Markus Heiser
230215c250 [fix] preferences: description not localized for all UI languages (#4844)
The previous implementation for determining the description of an engine did not
take into account that the UI languages ​​can also have a region tag and/or a
script tag:

    el-GR:      Ελληνικά, Ελλάδα (Greek, Greece)
    fa-IR:      فارسی, ایران (Persian, Iran)
    nb-NO:      Norsk bokmål, Norge (Norwegian bokmål, Norway)
    nl-BE:      Nederlands, België (Dutch, Belgium)
    pt-BR:      Português, Brasil (Portuguese, Brazil)
    zh-HK:      中文, 中國香港特別行政區 (Chinese, Hong Kong SAR China)
    zh-Hans-CN: 中文, 中国 (Chinese, China)
    zh-Hant-TW: 中文, 台灣 (Chinese, Taiwan)

Closes: https://github.com/searxng/searxng/issues/4842

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-05-23 17:11:41 +02:00
Markus Heiser
1ef5c03962 [fix] ddg engine: IndexError exception is raised on empty contend (#4843)
Sometimes (e.g. when ddg does not have a result item) there is no content and
the engine will fail with an IndexError:

  * Error: IndexError
  * Percentage: 10
  * Parameters: `()`
  * File name: `searx/engines/duckduckgo.py:375`
  * Function: `response`
  * Code: `item["content"] = extract_text(eval_xpath(div_result, './/a[contains(@class, "result__snippet")]')[0])`

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-05-23 14:55:22 +02:00
2 changed files with 9 additions and 5 deletions

View File

@@ -372,8 +372,9 @@ def response(resp) -> EngineResults:
continue
item["title"] = extract_text(title)
item["url"] = eval_xpath(div_result, './/h2/a/@href')[0]
item["content"] = extract_text(eval_xpath(div_result, './/a[contains(@class, "result__snippet")]')[0])
item["content"] = extract_text(
eval_xpath_getindex(div_result, './/a[contains(@class, "result__snippet")]', 0, [])
)
results.append(item)
zero_click_info_xpath = '//div[@id="zero_click_abstract"]'

View File

@@ -106,6 +106,7 @@ from searx.metrics import get_engines_stats, get_engine_errors, get_reliabilitie
from searx.flaskfix import patch_application
from searx.locales import (
LOCALE_BEST_MATCH,
LOCALE_NAMES,
RTL_LOCALES,
localeselector,
@@ -1059,10 +1060,12 @@ def image_proxy():
@app.route('/engine_descriptions.json', methods=['GET'])
def engine_descriptions():
locale = get_locale().split('_')[0]
sxng_ui_lang_tag = get_locale().replace("_", "-")
sxng_ui_lang_tag = LOCALE_BEST_MATCH.get(sxng_ui_lang_tag, sxng_ui_lang_tag)
result = ENGINE_DESCRIPTIONS['en'].copy()
if locale != 'en':
for engine, description in ENGINE_DESCRIPTIONS.get(locale, {}).items():
if sxng_ui_lang_tag != 'en':
for engine, description in ENGINE_DESCRIPTIONS.get(sxng_ui_lang_tag, {}).items():
result[engine] = description
for engine, description in result.items():
if len(description) == 2 and description[1] == 'ref':