on master help sign in
[enh] api_key usage, disable the engine by default
commit8c72a22757290754fc15fecb82dd157f6ea56a7f authorpotato <mail@crazypotato.tk> dateTue 6 Sep 2016, 16:12 (10 years ago) parentc051e6a
2 files changed+10−3
searx/engines/translated.py+8−2 searx/settings.yml+2−1
searx/engines/translated.py+8−2
@@ -7,11 +7,12 @@ from searx.languages import language_codes
77
88categories = ['general']
99url = 'http://api.mymemory.translated.net/get?q={query}' \
10− '&langpair={from_lang}|{to_lang}'
10+ '&langpair={from_lang}|{to_lang}{key}'
1111web_url = 'http://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
1212weight = 100
1313
1414parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
15+api_key = ''
1516
1617
1718def is_valid_lang(lang):
@@ -41,9 +42,14 @@ def request(query, params):
4142 if not from_lang or not to_lang:
4243 return params
4344
45+ if api_key:
46+ key_form = '&key=' + api_key
47+ else:
48+ key_form = ''
4449 params['url'] = url.format(from_lang=from_lang[1],
4550 to_lang=to_lang[1],
46− query=query)
51+ query=query,
52+ key=key_form)
4753 params['query'] = query
4854 params['from_lang'] = from_lang
4955 params['to_lang'] = to_lang
searx/settings.yml+2−1
@@ -7,7 +7,7 @@ search:
77 autocomplete : "" # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "startpage", "wikipedia" - leave blank to turn it off by default
88
99server:
10− port : 8888
10+ port : 8889
1111 bind_address : "127.0.0.1" # address to listen on
1212 secret_key : "ultrasecretkey" # change this!
1313 base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/"
@@ -503,6 +503,7 @@ engines:
503503 engine : translated
504504 shortcut : tl
505505 timeout : 5.0
506+ disabled : True
506507 # You can use without an API key, but you are limited to 1000 words/day
507508 # See : http://mymemory.translated.net/doc/usagelimits.php
508509 # api_key : ''