mirror of
https://github.com/searxng/searxng.git
synced 2025-07-24 13:49:26 +02:00
[enh] api_key usage, disable the engine by default
This commit is contained in:
parent
c051e6a2c3
commit
8c72a22757
2 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue