summaryrefslogtreecommitdiff
path: root/searx/engines/translated.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-12-16 16:20:03 +0100
committerAlexandre Flament <alex@al-f.net>2020-12-17 11:39:36 +0100
commit02fc4147ce745325ff25146a8085a915a5d3cacd (patch)
treec1e7b116220d72f9e541ff4e7e5b108dd8a2f2aa /searx/engines/translated.py
parent7ec8bc3ea76516e33318c67165161df5c1efdd36 (diff)
downloadsearxng-02fc4147ce745325ff25146a8085a915a5d3cacd.tar.gz
searxng-02fc4147ce745325ff25146a8085a915a5d3cacd.zip
[mod] dictzone, translated, currency_convert: use engine_type online_curency and online_dictionnary
Diffstat (limited to 'searx/engines/translated.py')
-rw-r--r--searx/engines/translated.py26
1 files changed, 4 insertions, 22 deletions
diff --git a/searx/engines/translated.py b/searx/engines/translated.py
index 75b8b5f42..2706e3617 100644
--- a/searx/engines/translated.py
+++ b/searx/engines/translated.py
@@ -8,44 +8,26 @@
@stable yes
@parse url, title, content
"""
-import re
-from searx.utils import is_valid_lang
+engine_type = 'online_dictionnary'
categories = ['general']
url = 'https://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}{key}'
web_url = 'https://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
weight = 100
https_support = True
-parser_re = re.compile('.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
api_key = ''
def request(query, params):
- m = parser_re.match(query)
- if not m:
- return params
-
- from_lang, to_lang, query = m.groups()
-
- from_lang = is_valid_lang(from_lang)
- to_lang = is_valid_lang(to_lang)
-
- 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,
+ params['url'] = url.format(from_lang=params['from_lang'][1],
+ to_lang=params['to_lang'][1],
+ query=params['query'],
key=key_form)
- params['query'] = query
- params['from_lang'] = from_lang
- params['to_lang'] = to_lang
-
return params