commit: 8c72a22757290754fc15fecb82dd157f6ea56a7f
parent c051e6a2c3e97419983d552594a6a8340339c1d5
Author: potato <mail@crazypotato.tk>
Date: Tue, 6 Sep 2016 16:12:34 +0200
[enh] api_key usage, disable the engine by default
Diffstat:
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git 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
diff --git a/searx/settings.yml b/searx/settings.yml
@@ -7,7 +7,7 @@ search:
autocomplete : "" # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "wikipedia" - leave blank to turn it off by default
server:
- port : 8888
+ port : 8889
bind_address : "127.0.0.1" # address to listen on
secret_key : "ultrasecretkey" # change this!
base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/"
@@ -503,6 +503,7 @@ engines:
engine : translated
shortcut : tl
timeout : 5.0
+ disabled : True
# You can use without an API key, but you are limited to 1000 words/day
# See : http://mymemory.translated.net/doc/usagelimits.php
# api_key : ''