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 }}-
path: "./local/"
- name: Setup dependencies
run: sudo ./utils/searxng.sh install buildhost
- name: Setup venv
run: make V=1 install
- name: Build documentation
run: make V=1 docs.clean docs.html
run: make V=1 docs.html
- if: github.ref_name == 'master'
name: Release
+8 -7
View File
@@ -1,10 +1,11 @@
[[language]]
name = "python"
language-servers = ["basedpyright", "pylsp"]
formatter = { command = "black", args = [
"--target-version",
"py311",
"--line-length",
"120",
"--skip-string-normalization",
] }
auto-format = true
[language-server.pylsp.config.pylsp]
plugins.pylint.enabled = true
plugins.isort.enabled = true
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
"""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
"""
@@ -46,15 +47,12 @@ CACHE_VALID_DURATION = 30 * 24 * 3600 # one month, same as website
"""Duration how long settings cookies are valid."""
def init(_):
if fireball_category not in ("web", "news", "videos"):
raise ValueError(f"Unsupported category: {fireball_category}")
def setup(engine_settings: dict[str, t.Any]) -> bool:
def init(engine_settings: dict[str, t.Any]):
global CACHE # pylint: disable=global-statement
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:
@@ -62,13 +60,12 @@ def _cache_key(fireball_settings: dict[str, str]) -> str:
def _get_search_settings_cookie(params: 'OnlineParams') -> str:
"""
Get a 'fireball' cookie for the given locale and safesearch setting set in params.
"""
"""Get a 'fireball' cookie for the given locale and safesearch setting set
in params."""
# the language is set by only specifying the search country
# on their website, they only list DE and US, but in fact it
# supports much more countries
# the language is set by only specifying the search country on their
# website, they only list DE and US, but in fact it supports much more
# countries
country = "US"
if params["searxng_locale"] != "all":
language_parts = params["searxng_locale"].split("-")
@@ -101,9 +98,9 @@ def _get_search_settings_cookie(params: 'OnlineParams') -> str:
return cookie
def request(query: str, params: 'OnlineParams'):
# no matter the category, the request is always the same
# i.e. we get all different categories with one HTTP request
def request(query: str, params: "OnlineParams"):
# no matter the category, the request is always the same, i.e. we get all
# different categories with one HTTP request
args = {
"f": "web",
@@ -117,7 +114,7 @@ def request(query: str, params: 'OnlineParams'):
params["headers"]["Referer"] = f"{base_url}/search?{urlencode(args)}"
def response(resp: 'SXNG_Response') -> EngineResults:
def response(resp: "SXNG_Response") -> EngineResults:
res = EngineResults()
json_data = resp.json()
@@ -151,10 +148,6 @@ def response(resp: 'SXNG_Response') -> EngineResults:
)
)
elif fireball_category == "videos":
thumbnail = None
if result.get("thumbnail"):
thumbnail = result["thumbnail"]["original"]
length = None
if result.get("video"):
length = result["video"].get("duration")
@@ -166,7 +159,7 @@ def response(resp: 'SXNG_Response') -> EngineResults:
"url": result["url"],
"title": html_to_text(result["title"]),
"content": html_to_text(result["description"]),
"thumbnail": thumbnail,
"thumbnail": result.get("thumbnail", {}).get("original"),
"length": length,
"publishedDate": published_date,
}