summaryrefslogtreecommitdiff
path: root/searx/plugins
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2021-09-10 09:20:26 +0000
committerGitHub <noreply@github.com>2021-09-10 09:20:26 +0000
commitb671e0364fbfb09701fb675ba23a7d7bebbcf744 (patch)
tree5cc14908449328de044464fbccb4950d08632a99 /searx/plugins
parent449ff708985b86c85a4badc8494a577c792c4dd7 (diff)
parent0b27c8698f7b5bbca5083cf234fabbc7d7308349 (diff)
downloadsearxng-b671e0364fbfb09701fb675ba23a7d7bebbcf744.tar.gz
searxng-b671e0364fbfb09701fb675ba23a7d7bebbcf744.zip
Merge pull request #302 from dalf/mod_plugin_on_result
[mod] plugin: call on_result for each result of each engines.
Diffstat (limited to 'searx/plugins')
-rw-r--r--searx/plugins/ahmia_filter.py8
-rw-r--r--searx/plugins/oa_doi_rewrite.py15
2 files changed, 7 insertions, 16 deletions
diff --git a/searx/plugins/ahmia_filter.py b/searx/plugins/ahmia_filter.py
index 83b05e4d2..70f216ee1 100644
--- a/searx/plugins/ahmia_filter.py
+++ b/searx/plugins/ahmia_filter.py
@@ -20,14 +20,8 @@ def get_ahmia_blacklist():
return ahmia_blacklist
-def not_blacklisted(result):
+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 get_ahmia_blacklist()
-
-
-def post_search(request, search):
- filtered_results = list(filter(not_blacklisted, search.result_container._merged_results))
- search.result_container._merged_results = filtered_results
- return True
diff --git a/searx/plugins/oa_doi_rewrite.py b/searx/plugins/oa_doi_rewrite.py
index 02a712942..2dcc01e05 100644
--- a/searx/plugins/oa_doi_rewrite.py
+++ b/searx/plugins/oa_doi_rewrite.py
@@ -11,8 +11,6 @@ description = gettext('Avoid paywalls by redirecting to open-access versions of
default_on = False
preference_section = 'general'
-doi_resolvers = settings['doi_resolvers']
-
def extract_doi(url):
match = regex.search(url.path)
@@ -25,13 +23,12 @@ def extract_doi(url):
return None
-def get_doi_resolver(args, preference_doi_resolver):
+def get_doi_resolver(preferences):
doi_resolvers = settings['doi_resolvers']
- doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0]
- if doi_resolver not in doi_resolvers:
- doi_resolver = settings['default_doi_resolver']
- doi_resolver_url = doi_resolvers[doi_resolver]
- return doi_resolver_url
+ selected_resolver = preferences.get_value('doi_resolver')[0]
+ if selected_resolver not in doi_resolvers:
+ selected_resolver = settings['default_doi_resolver']
+ return doi_resolvers[selected_resolver]
def on_result(request, search, result):
@@ -43,6 +40,6 @@ def on_result(request, search, result):
for suffix in ('/', '.pdf', '.xml', '/full', '/meta', '/abstract'):
if doi.endswith(suffix):
doi = doi[:-len(suffix)]
- result['url'] = get_doi_resolver(request.args, request.preferences.get_value('doi_resolver')) + doi
+ result['url'] = get_doi_resolver(request.preferences) + doi
result['parsed_url'] = urlparse(result['url'])
return True