summaryrefslogtreecommitdiff
path: root/searx/plugins
diff options
context:
space:
mode:
authorNoémi Ványi <sitbackandwait@gmail.com>2017-11-01 13:58:48 +0100
committerNoémi Ványi <sitbackandwait@gmail.com>2017-11-01 17:02:38 +0100
commit1b10abfc92afed36627c7052b89d2de5e7f537ee (patch)
treee128d2ba42fa63b970e99e35a4c0c7d80d35f952 /searx/plugins
parent575159b194440052d7b48aa073d7e03c80799c90 (diff)
downloadsearxng-1b10abfc92afed36627c7052b89d2de5e7f537ee.tar.gz
searxng-1b10abfc92afed36627c7052b89d2de5e7f537ee.zip
minor fixes of doi resolver
Closes #1047
Diffstat (limited to 'searx/plugins')
-rw-r--r--searx/plugins/oa_doi_rewrite.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/searx/plugins/oa_doi_rewrite.py b/searx/plugins/oa_doi_rewrite.py
index e952c86f5..b62ef0b1e 100644
--- a/searx/plugins/oa_doi_rewrite.py
+++ b/searx/plugins/oa_doi_rewrite.py
@@ -1,7 +1,6 @@
from flask_babel import gettext
import re
from searx.url_utils import urlparse, parse_qsl
-from flask import request
from searx import settings
@@ -26,12 +25,12 @@ def extract_doi(url):
return None
-def get_doi_resolver():
+def get_doi_resolver(args, preference_doi_resolver):
doi_resolvers = settings['doi_resolvers']
- doi_resolver = request.args.get('doi_resolver', request.preferences.get_value('doi_resolver'))[0]
+ doi_resolver = args.get('doi_resolver', preference_doi_resolver)[0]
if doi_resolver not in doi_resolvers:
doi_resolvers = settings['default_doi_resolver']
- return doi_resolvers[doi_resolver]
+ return doi_resolver
def on_result(request, search, result):
@@ -40,6 +39,6 @@ def on_result(request, search, result):
for suffix in ('/', '.pdf', '/full', '/meta', '/abstract'):
if doi.endswith(suffix):
doi = doi[:-len(suffix)]
- result['url'] = get_doi_resolver() + doi
+ result['url'] = get_doi_resolver(request.args, request.preferences.get_value('doi_resolver')) + doi
result['parsed_url'] = urlparse(result['url'])
return True