diff options
Diffstat (limited to 'searx/plugins')
-rw-r--r-- | searx/plugins/ahmia_filter.py | 8 | ||||
-rw-r--r-- | searx/plugins/oa_doi_rewrite.py | 15 |
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 |