diff options
author | Alexandre Flament <alex@al-f.net> | 2021-09-06 08:47:11 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-09-07 19:14:36 +0200 |
commit | fc20c561bf540d9b187a89a71730b6e3b0bee2da (patch) | |
tree | 64600325ef826757115b57e3369d346a0997a0d8 /searx/plugins | |
parent | a3789b3bb44fd929a730518da678b7754a2c18cb (diff) | |
download | searxng-fc20c561bf540d9b187a89a71730b6e3b0bee2da.tar.gz searxng-fc20c561bf540d9b187a89a71730b6e3b0bee2da.zip |
[mod] oa_doi_rewrite plugin: get_doi_resolver: remove args parameter
doi_resolvers.get_value('preferences') already contains the value from
request.args.get('doi_resolver')
Diffstat (limited to 'searx/plugins')
-rw-r--r-- | searx/plugins/oa_doi_rewrite.py | 15 |
1 files changed, 6 insertions, 9 deletions
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 |