summaryrefslogtreecommitdiff
path: root/searx/engines/translated.py
diff options
context:
space:
mode:
authorpotato <mail@crazypotato.tk>2016-09-06 16:12:34 +0200
committerpotato <mail@crazypotato.tk>2016-09-06 16:12:34 +0200
commit8c72a22757290754fc15fecb82dd157f6ea56a7f (patch)
treecd93a75690adde9dbc3d61d65e74f3c539870e71 /searx/engines/translated.py
parentc051e6a2c3e97419983d552594a6a8340339c1d5 (diff)
downloadsearxng-8c72a22757290754fc15fecb82dd157f6ea56a7f.tar.gz
searxng-8c72a22757290754fc15fecb82dd157f6ea56a7f.zip
[enh] api_key usage, disable the engine by default
Diffstat (limited to 'searx/engines/translated.py')
-rw-r--r--searx/engines/translated.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/searx/engines/translated.py b/searx/engines/translated.py
index 2f535140c..3be9d4adf 100644
--- a/searx/engines/translated.py
+++ b/searx/engines/translated.py
@@ -7,11 +7,12 @@ from searx.languages import language_codes
categories = ['general']
url = 'http://api.mymemory.translated.net/get?q={query}' \
- '&langpair={from_lang}|{to_lang}'
+ '&langpair={from_lang}|{to_lang}{key}'
web_url = 'http://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
weight = 100
parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
+api_key = ''
def is_valid_lang(lang):
@@ -41,9 +42,14 @@ def request(query, params):
if not from_lang or not to_lang:
return params
+ if api_key:
+ key_form = '&key=' + api_key
+ else:
+ key_form = ''
params['url'] = url.format(from_lang=from_lang[1],
to_lang=to_lang[1],
- query=query)
+ query=query,
+ key=key_form)
params['query'] = query
params['from_lang'] = from_lang
params['to_lang'] = to_lang