.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.plugins.oa_doi_rewrite Namespace Reference

Functions

 extract_doi (url)
 
 get_doi_resolver (preferences)
 
 on_result (request, _search, result)
 

Variables

 regex = re.compile(r'10\.\d{4,9}/[^\s]+')
 
 name = gettext('Open Access DOI rewrite')
 
 description = gettext('Avoid paywalls by redirecting to open-access versions of publications when available')
 
bool default_on = False
 
str preference_section = 'general'
 

Function Documentation

◆ extract_doi()

searx.plugins.oa_doi_rewrite.extract_doi ( url)

Definition at line 18 of file oa_doi_rewrite.py.

18def extract_doi(url):
19 match = regex.search(url.path)
20 if match:
21 return match.group(0)
22 for _, v in parse_qsl(url.query):
23 match = regex.search(v)
24 if match:
25 return match.group(0)
26 return None
27
28

Referenced by searx.plugins.oa_doi_rewrite.on_result().

+ Here is the caller graph for this function:

◆ get_doi_resolver()

searx.plugins.oa_doi_rewrite.get_doi_resolver ( preferences)

Definition at line 29 of file oa_doi_rewrite.py.

29def get_doi_resolver(preferences):
30 doi_resolvers = settings['doi_resolvers']
31 selected_resolver = preferences.get_value('doi_resolver')[0]
32 if selected_resolver not in doi_resolvers:
33 selected_resolver = settings['default_doi_resolver']
34 return doi_resolvers[selected_resolver]
35
36

◆ on_result()

searx.plugins.oa_doi_rewrite.on_result ( request,
_search,
result )

Definition at line 37 of file oa_doi_rewrite.py.

37def on_result(request, _search, result):
38 if 'parsed_url' not in result:
39 return True
40
41 doi = extract_doi(result['parsed_url'])
42 if doi and len(doi) < 50:
43 for suffix in ('/', '.pdf', '.xml', '/full', '/meta', '/abstract'):
44 if doi.endswith(suffix):
45 doi = doi[: -len(suffix)]
46 result['url'] = get_doi_resolver(request.preferences) + doi
47 result['parsed_url'] = urlparse(result['url'])
48 if 'doi' not in result:
49 result['doi'] = doi
50 return True

References searx.plugins.oa_doi_rewrite.extract_doi().

+ Here is the call graph for this function:

Variable Documentation

◆ default_on

bool searx.plugins.oa_doi_rewrite.default_on = False

Definition at line 14 of file oa_doi_rewrite.py.

◆ description

searx.plugins.oa_doi_rewrite.description = gettext('Avoid paywalls by redirecting to open-access versions of publications when available')

Definition at line 13 of file oa_doi_rewrite.py.

◆ name

searx.plugins.oa_doi_rewrite.name = gettext('Open Access DOI rewrite')

Definition at line 12 of file oa_doi_rewrite.py.

◆ preference_section

str searx.plugins.oa_doi_rewrite.preference_section = 'general'

Definition at line 15 of file oa_doi_rewrite.py.

◆ regex

searx.plugins.oa_doi_rewrite.regex = re.compile(r'10\.\d{4,9}/[^\s]+')

Definition at line 10 of file oa_doi_rewrite.py.