|
@@ -6,12 +6,14 @@ from searx.engines.xpath import extract_text
|
6
|
6
|
from searx.languages import language_codes
|
7
|
7
|
|
8
|
8
|
categories = ['general']
|
9
|
|
-url = 'http://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}'
|
|
9
|
+url = 'http://api.mymemory.translated.net/get?q={query}' \
|
|
10
|
+ '&langpair={from_lang}|{to_lang}'
|
10
|
11
|
web_url = 'http://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
|
11
|
12
|
weight = 100
|
12
|
13
|
|
13
|
14
|
parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
|
14
|
15
|
|
|
16
|
+
|
15
|
17
|
def is_valid_lang(lang):
|
16
|
18
|
is_abbr = (len(lang) == 2)
|
17
|
19
|
if is_abbr:
|
|
@@ -52,12 +54,14 @@ def request(query, params):
|
52
|
54
|
def response(resp):
|
53
|
55
|
results = []
|
54
|
56
|
results.append({
|
55
|
|
- 'url': escape(web_url.format(from_lang=resp.search_params['from_lang'][2],
|
56
|
|
- to_lang=resp.search_params['to_lang'][2],
|
57
|
|
- query=resp.search_params['query'])),
|
58
|
|
- 'title': escape('[{0}-{1}] {2}'.format(resp.search_params['from_lang'][1],
|
59
|
|
- resp.search_params['to_lang'][1],
|
60
|
|
- resp.search_params['query'])),
|
|
57
|
+ 'url': escape(web_url.format(
|
|
58
|
+ from_lang=resp.search_params['from_lang'][2],
|
|
59
|
+ to_lang=resp.search_params['to_lang'][2],
|
|
60
|
+ query=resp.search_params['query'])),
|
|
61
|
+ 'title': escape('[{0}-{1}] {2}'.format(
|
|
62
|
+ resp.search_params['from_lang'][1],
|
|
63
|
+ resp.search_params['to_lang'][1],
|
|
64
|
+ resp.search_params['query'])),
|
61
|
65
|
'content': escape(resp.json()['responseData']['translatedText'])
|
62
|
66
|
})
|
63
|
67
|
return results
|