forked from zaclys/searxng
Merge pull request #849 from return42/fix-787
[fix] engines description - currency_convert.py
This commit is contained in:
commit
07f7289e23
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""
|
# lint: pylint
|
||||||
currency convert (DuckDuckGo)
|
"""Currency convert (DuckDuckGo)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -13,18 +13,19 @@ about = {
|
||||||
"use_official_api": False,
|
"use_official_api": False,
|
||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": 'JSONP',
|
"results": 'JSONP',
|
||||||
|
"description": "Service from DuckDuckGo.",
|
||||||
}
|
}
|
||||||
|
|
||||||
engine_type = 'online_currency'
|
engine_type = 'online_currency'
|
||||||
categories = []
|
categories = []
|
||||||
url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'
|
base_url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'
|
||||||
weight = 100
|
weight = 100
|
||||||
|
|
||||||
https_support = True
|
https_support = True
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(_query, params):
|
||||||
params['url'] = url.format(params['from'], params['to'])
|
params['url'] = base_url.format(params['from'], params['to'])
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ def response(resp):
|
||||||
results = []
|
results = []
|
||||||
try:
|
try:
|
||||||
conversion_rate = float(json.loads(json_resp)['conversion']['converted-amount'])
|
conversion_rate = float(json.loads(json_resp)['conversion']['converted-amount'])
|
||||||
except:
|
except ValueError:
|
||||||
return results
|
return results
|
||||||
answer = '{0} {1} = {2} {3}, 1 {1} ({5}) = {4} {3} ({6})'.format(
|
answer = '{0} {1} = {2} {3}, 1 {1} ({5}) = {4} {3} ({6})'.format(
|
||||||
resp.search_params['amount'],
|
resp.search_params['amount'],
|
||||||
|
|
Loading…
Reference in New Issue