on master help sign in
[fix] kickass engine : change the hostname to kickass.to (since kickass.so doesn't respond).

Close #197 perhaps not in clean way. Explanation : In fact 301 responses are followed, except the hook is called for each HTTP response, the first time for the HTTP 301 response then for HTTP 200 response. Since the kickass engine excepts a real result, the engine crashes, AND the requests lib stops here. Add a simple test at the beginning of the result function allows pass the first response and handle correctly the second response (the real one) May be a proper way is to add this test in search.py ? Code inside requests : https://github.com/kennethreitz/requests/blob/53d02381e22436b6d0757eb305eb1a960f82d361/requests/sessions.py#L579 and line 591

commit9db0bbc30421cec9d42438ccab748439eea60105 authordalf <alex@al-f.net> dateThu 12 Feb 2015, 12:30 (12 years ago) parentf8a5f7d
2 files changed+9−4
searx/engines/kickass.py+6−1 searx/tests/engines/test_kickass.py+3−3
searx/engines/kickass.py+6−1
@@ -20,7 +20,7 @@ categories = ['videos', 'music', 'files']
2020paging = True
2121
2222# search-url
23−url = 'https://kickass.so/'
23+url = 'https://kickass.to/'
2424search_url = url + 'search/{search_term}/{pageno}/'
2525
2626# specific xpath variables
@@ -45,6 +45,11 @@ def request(query, params):
4545def response(resp):
4646 results = []
4747
48+ # check if redirect comparing to the True value,
49+ # because resp can be a Mock object, and any attribut name returns something.
50+ if resp.is_redirect == True:
51+ return results
52+
4853 dom = html.fromstring(resp.text)
4954
5055 search_res = dom.xpath('//table[@class="data"]//tr')
searx/tests/engines/test_kickass.py+3−3
@@ -14,7 +14,7 @@ class TestKickassEngine(SearxTestCase):
1414 params = kickass.request(query, dicto)
1515 self.assertIn('url', params)
1616 self.assertIn(query, params['url'])
17− self.assertIn('kickass.so', params['url'])
17+ self.assertIn('kickass.to', params['url'])
1818 self.assertIn('verify', params)
1919 self.assertFalse(params['verify'])
2020
@@ -98,7 +98,7 @@ class TestKickassEngine(SearxTestCase):
9898 self.assertEqual(type(results), list)
9999 self.assertEqual(len(results), 1)
100100 self.assertEqual(results[0]['title'], 'This should be the title')
101− self.assertEqual(results[0]['url'], 'https://kickass.so/url.html')
101+ self.assertEqual(results[0]['url'], 'https://kickass.to/url.html')
102102 self.assertEqual(results[0]['content'], 'Posted by riri in Other &gt; Unsorted')
103103 self.assertEqual(results[0]['seed'], 10)
104104 self.assertEqual(results[0]['leech'], 1)
@@ -381,7 +381,7 @@ class TestKickassEngine(SearxTestCase):
381381 self.assertEqual(type(results), list)
382382 self.assertEqual(len(results), 5)
383383 self.assertEqual(results[0]['title'], 'This should be the title')
384− self.assertEqual(results[0]['url'], 'https://kickass.so/url.html')
384+ self.assertEqual(results[0]['url'], 'https://kickass.to/url.html')
385385 self.assertEqual(results[0]['content'], 'Posted by riri in Other &gt; Unsorted')
386386 self.assertEqual(results[0]['seed'], 10)
387387 self.assertEqual(results[0]['leech'], 1)