.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
ahmia_filter.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2# pylint: disable=missing-module-docstring
3
4from hashlib import md5
5from searx.data import ahmia_blacklist_loader
6
7name = "Ahmia blacklist"
8description = "Filter out onion results that appear in Ahmia's blacklist. (See https://ahmia.fi/blacklist)"
9default_on = True
10preference_section = 'onions'
11
12ahmia_blacklist = None
13
14
15def on_result(_request, _search, result):
16 if not result.get('is_onion') or not result.get('parsed_url'):
17 return True
18 result_hash = md5(result['parsed_url'].hostname.encode()).hexdigest()
19 return result_hash not in ahmia_blacklist
20
21
22def init(_app, settings):
23 global ahmia_blacklist # pylint: disable=global-statement
24 if not settings['outgoing']['using_tor_proxy']:
25 # disable the plugin
26 return False
27 ahmia_blacklist = ahmia_blacklist_loader()
28 return True
on_result(_request, _search, result)