return search url for bangs if no direct result is available
This commit is contained in:
@@ -757,6 +757,8 @@ def search_the_web(argv, **args):
|
|||||||
response = requests.get(url, params=params).json()
|
response = requests.get(url, params=params).json()
|
||||||
link = response.get('AbstractURL')
|
link = response.get('AbstractURL')
|
||||||
abstract = response.get('Abstract')
|
abstract = response.get('Abstract')
|
||||||
|
redirect = response.get('Redirect')
|
||||||
|
|
||||||
if len(abstract) > 150:
|
if len(abstract) > 150:
|
||||||
suffix = '…'
|
suffix = '…'
|
||||||
else:
|
else:
|
||||||
@@ -766,6 +768,10 @@ def search_the_web(argv, **args):
|
|||||||
return {
|
return {
|
||||||
'msg': '{}{} ({})'.format(abstract[:150], suffix, link)
|
'msg': '{}{} ({})'.format(abstract[:150], suffix, link)
|
||||||
}
|
}
|
||||||
|
elif redirect:
|
||||||
|
return {
|
||||||
|
'msg': 'No direct result found, use {}'.format(redirect)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pluginfunction('raise', 'only for debugging', ptypes_COMMAND)
|
@pluginfunction('raise', 'only for debugging', ptypes_COMMAND)
|
||||||
|
|||||||
Reference in New Issue
Block a user