Compare commits

..

3 Commits

Author SHA1 Message Date
Bnyro a1490676e3 [mod] fireball: small fixup from code review (#6240)
Co-authored-by: Markus Heiser <markus.heiser@darmarIT.de>
2026-06-11 12:09:57 +02:00
Bnyro 3a382cb3f3 [chore] helix config: enable pyling and use black via pylsp 2026-06-11 11:03:38 +02:00
Ivan Gabaldon 9d9d605b15 [fix] ci: use install buildhost script (#6105) 2026-06-11 08:23:37 +02:00
3 changed files with 28 additions and 31 deletions
+4 -1
View File
@@ -50,11 +50,14 @@ jobs:
python-${{ env.PYTHON_VERSION }}-${{ runner.arch }}- python-${{ env.PYTHON_VERSION }}-${{ runner.arch }}-
path: "./local/" path: "./local/"
- name: Setup dependencies
run: sudo ./utils/searxng.sh install buildhost
- name: Setup venv - name: Setup venv
run: make V=1 install run: make V=1 install
- name: Build documentation - name: Build documentation
run: make V=1 docs.clean docs.html run: make V=1 docs.html
- if: github.ref_name == 'master' - if: github.ref_name == 'master'
name: Release name: Release
+8 -7
View File
@@ -1,10 +1,11 @@
[[language]] [[language]]
name = "python" name = "python"
language-servers = ["basedpyright", "pylsp"] language-servers = ["basedpyright", "pylsp"]
formatter = { command = "black", args = [ auto-format = true
"--target-version",
"py311", [language-server.pylsp.config.pylsp]
"--line-length", plugins.pylint.enabled = true
"120", plugins.isort.enabled = true
"--skip-string-normalization", plugins.black.enabled = true
] } plugins.black.skip_string_normalization = true
plugins.black.line_length = 120
+16 -23
View File
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
"""Fireball_ is a Germany-based, privacy-focused search engine. """Fireball_ is a Germany-based, privacy-focused search engine.
It likely doesn't have its own index, but it's unclear where its results come from. It likely doesn't have its own index, but it's unclear where its results come
from.
.. _Fireball: https://fireball.com .. _Fireball: https://fireball.com
""" """
@@ -46,15 +47,12 @@ CACHE_VALID_DURATION = 30 * 24 * 3600 # one month, same as website
"""Duration how long settings cookies are valid.""" """Duration how long settings cookies are valid."""
def init(_): def init(engine_settings: dict[str, t.Any]):
if fireball_category not in ("web", "news", "videos"):
raise ValueError(f"Unsupported category: {fireball_category}")
def setup(engine_settings: dict[str, t.Any]) -> bool:
global CACHE # pylint: disable=global-statement global CACHE # pylint: disable=global-statement
CACHE = EngineCache(engine_settings["name"]) CACHE = EngineCache(engine_settings["name"])
return True
if fireball_category not in ("web", "news", "videos"):
raise ValueError(f"Unsupported category: {fireball_category}")
def _cache_key(fireball_settings: dict[str, str]) -> str: def _cache_key(fireball_settings: dict[str, str]) -> str:
@@ -62,13 +60,12 @@ def _cache_key(fireball_settings: dict[str, str]) -> str:
def _get_search_settings_cookie(params: 'OnlineParams') -> str: def _get_search_settings_cookie(params: 'OnlineParams') -> str:
""" """Get a 'fireball' cookie for the given locale and safesearch setting set
Get a 'fireball' cookie for the given locale and safesearch setting set in params. in params."""
"""
# the language is set by only specifying the search country # the language is set by only specifying the search country on their
# on their website, they only list DE and US, but in fact it # website, they only list DE and US, but in fact it supports much more
# supports much more countries # countries
country = "US" country = "US"
if params["searxng_locale"] != "all": if params["searxng_locale"] != "all":
language_parts = params["searxng_locale"].split("-") language_parts = params["searxng_locale"].split("-")
@@ -101,9 +98,9 @@ def _get_search_settings_cookie(params: 'OnlineParams') -> str:
return cookie return cookie
def request(query: str, params: 'OnlineParams'): def request(query: str, params: "OnlineParams"):
# no matter the category, the request is always the same # no matter the category, the request is always the same, i.e. we get all
# i.e. we get all different categories with one HTTP request # different categories with one HTTP request
args = { args = {
"f": "web", "f": "web",
@@ -117,7 +114,7 @@ def request(query: str, params: 'OnlineParams'):
params["headers"]["Referer"] = f"{base_url}/search?{urlencode(args)}" params["headers"]["Referer"] = f"{base_url}/search?{urlencode(args)}"
def response(resp: 'SXNG_Response') -> EngineResults: def response(resp: "SXNG_Response") -> EngineResults:
res = EngineResults() res = EngineResults()
json_data = resp.json() json_data = resp.json()
@@ -151,10 +148,6 @@ def response(resp: 'SXNG_Response') -> EngineResults:
) )
) )
elif fireball_category == "videos": elif fireball_category == "videos":
thumbnail = None
if result.get("thumbnail"):
thumbnail = result["thumbnail"]["original"]
length = None length = None
if result.get("video"): if result.get("video"):
length = result["video"].get("duration") length = result["video"].get("duration")
@@ -166,7 +159,7 @@ def response(resp: 'SXNG_Response') -> EngineResults:
"url": result["url"], "url": result["url"],
"title": html_to_text(result["title"]), "title": html_to_text(result["title"]),
"content": html_to_text(result["description"]), "content": html_to_text(result["description"]),
"thumbnail": thumbnail, "thumbnail": result.get("thumbnail", {}).get("original"),
"length": length, "length": length,
"publishedDate": published_date, "publishedDate": published_date,
} }