@@ -11,6 +11,7 @@
1111from cgi import escape
1212from urllib import quote_plus
1313from lxml import html
14+from searx.languages import language_codes
1415
1516# engine dependent config
1617categories = ['videos']
@@ -38,13 +39,22 @@ def response(resp):
3839
3940 dom = html.fromstring(resp.text)
4041
42+ search_lang = ""
43+
44+ if resp.search_params['language'] != 'all':
45+ search_lang = [lc[1]
46+ for lc in language_codes
47+ if lc[0][:2] == resp.search_params['language']][0]
48+
4149 # parse results
4250 for result in dom.xpath(results_xpath):
4351 link = result.xpath(".//a")[0]
4452 href = link.attrib.get('href')
4553
4654 if language is not "":
47− href = href + language + "/"
55+ href = href + language + '/'
56+ elif search_lang:
57+ href = href + search_lang + '/'
4858
4959 title = escape(link.xpath(".//text()")[0])
5060