3from __future__
import annotations
7from flask_babel
import gettext
10from searx
import get_setting
13if typing.TYPE_CHECKING:
20ahmia_blacklist: list = []
24 """Filter out onion results that appear in Ahmia's blacklist (See https://ahmia.fi/blacklist)."""
28 def __init__(self, plg_cfg:
"PluginCfg") ->
None:
32 name=gettext(
"Ahmia blacklist"),
33 description=gettext(
"Filter out onion results that appear in Ahmia's blacklist."),
34 preference_section=
"general",
38 self, request:
"SXNG_Request", search:
"SearchWithPlugins", result: Result
40 if not getattr(result,
"is_onion",
False)
or not getattr(result,
"parsed_url",
False):
42 result_hash = md5(result[
"parsed_url"].hostname.encode()).hexdigest()
43 return result_hash
not in ahmia_blacklist
45 def init(self, app:
"flask.Flask") -> bool:
46 global ahmia_blacklist
50 ahmia_blacklist = ahmia_blacklist_loader()
None __init__(self, "PluginCfg" plg_cfg)
bool init(self, "flask.Flask" app)
bool on_result(self, "SXNG_Request" request, "SearchWithPlugins" search, Result result)
get_setting(name, default=_unset)