mirror of
https://github.com/searxng/searxng.git
synced 2024-05-10 07:32:40 +00:00
542f7d0d7b
In the past, some files were tested with the standard profile, others with a profile in which most of the messages were switched off ... some files were not checked at all. - ``PYLINT_SEARXNG_DISABLE_OPTION`` has been abolished - the distinction ``# lint: pylint`` is no longer necessary - the pylint tasks have been reduced from three to two 1. ./searx/engines -> lint engines with additional builtins 2. ./searx ./searxng_extra ./tests -> lint all other python files Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
29 lines
872 B
Python
29 lines
872 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# pylint: disable=missing-module-docstring
|
|
|
|
from hashlib import md5
|
|
from searx.data import ahmia_blacklist_loader
|
|
|
|
name = "Ahmia blacklist"
|
|
description = "Filter out onion results that appear in Ahmia's blacklist. (See https://ahmia.fi/blacklist)"
|
|
default_on = True
|
|
preference_section = 'onions'
|
|
|
|
ahmia_blacklist = None
|
|
|
|
|
|
def on_result(_request, _search, result):
|
|
if not result.get('is_onion') or not result.get('parsed_url'):
|
|
return True
|
|
result_hash = md5(result['parsed_url'].hostname.encode()).hexdigest()
|
|
return result_hash not in ahmia_blacklist
|
|
|
|
|
|
def init(_app, settings):
|
|
global ahmia_blacklist # pylint: disable=global-statement
|
|
if not settings['outgoing']['using_tor_proxy']:
|
|
# disable the plugin
|
|
return False
|
|
ahmia_blacklist = ahmia_blacklist_loader()
|
|
return True
|