From 785cbc50d1a38916876c1302c182bce26e1c9b62 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 14 Sep 2022 01:33:20 +0530 Subject: [PATCH 1/4] some more error fixes --- searx/engines/qwant.py | 4 +++- searx/settings.yml | 13 +++---------- searx/webapp.py | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index cee2dfa97..a6964c19c 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -93,6 +93,8 @@ def request(query, params): supported_languages, language_aliases, ) + if language not in supported_languages: + language = 'en-US' params['url'] += '&locale=' + language.replace('-', '_') params['raise_for_httperror'] = False @@ -252,5 +254,5 @@ def _fetch_supported_languages(resp): for lang in langs['langs']: lang_code = "{lang}-{country}".format(lang=lang, country=country) supported_languages.append(lang_code) - + return supported_languages diff --git a/searx/settings.yml b/searx/settings.yml index 2057c4dd8..c05689759 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -412,7 +412,7 @@ engines: - name: wikidata engine: wikidata shortcut: wd - timeout: 3.0 + timeout: 6.0 weight: 2 tests: *tests_infobox @@ -589,6 +589,7 @@ engines: - name : google images engine : google_images shortcut : goi + timeout: 6.0 # additional_tests: # android: *test_android # dali: @@ -741,19 +742,11 @@ engines: - name : invidious engine : invidious - base_url : - - https://invidious.tube/ - - https://invidious.snopyta.org/ + base_url : https://invidious.weblibre.org/ shortcut: iv timeout : 5.0 disabled : True - - name: kickass - engine : kickass - shortcut : kc - timeout : 4.0 - disabled : True - - name : library genesis engine : xpath paging : True diff --git a/searx/webapp.py b/searx/webapp.py index 5a0f279a4..2d5c780b6 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -619,7 +619,7 @@ def search(): # output_format output_format = request.form.get('format', 'html') - if output_format not in ['html', 'csv', 'json', 'rss']: + if output_format not in ['html', 'rss']: output_format = 'html' # check if there is query (not None and not an empty string) -- GitLab From 89696b02759e326e031729739e995fbef11c84cd Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 15 Sep 2022 01:59:18 +0530 Subject: [PATCH 2/4] fix pep8 --- searx/engines/qwant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index a6964c19c..e2ac19465 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -254,5 +254,5 @@ def _fetch_supported_languages(resp): for lang in langs['langs']: lang_code = "{lang}-{country}".format(lang=lang, country=country) supported_languages.append(lang_code) - + return supported_languages -- GitLab From 10975fd2250da1569d845e13a58b201e1c9c5cd4 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 15 Sep 2022 15:53:50 +0530 Subject: [PATCH 3/4] remove json and csv resultsg --- tests/unit/test_webapp.py | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index 92f6bb119..f0faa815a 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -98,14 +98,6 @@ class ViewsTestCase(SearxTestCase): self.assertEqual(result.status_code, 200) self.assertIn(b'Spot', result.data) - def test_search_empty_json(self): - result = self.app.post('/search', data={'q': '', 'format': 'json'}) - self.assertEqual(result.status_code, 400) - - def test_search_empty_csv(self): - result = self.app.post('/search', data={'q': '', 'format': 'csv'}) - self.assertEqual(result.status_code, 400) - def test_search_empty_rss(self): result = self.app.post('/search', data={'q': '', 'format': 'rss'}) self.assertEqual(result.status_code, 400) @@ -124,33 +116,7 @@ class ViewsTestCase(SearxTestCase): result.data ) - def test_index_json(self): - result = self.app.post('/', data={'q': 'test', 'format': 'json'}) - self.assertEqual(result.status_code, 308) - - def test_search_json(self): - result = self.app.post('/search', data={'q': 'test', 'format': 'json'}) - result_dict = json.loads(result.data.decode()) - - self.assertEqual('test', result_dict['query']) - self.assertEqual(len(result_dict['results']), 2) - self.assertEqual(result_dict['results'][0]['content'], 'first test content') - self.assertEqual(result_dict['results'][0]['url'], 'http://first.test.xyz') - - def test_index_csv(self): - result = self.app.post('/', data={'q': 'test', 'format': 'csv'}) - self.assertEqual(result.status_code, 308) - - def test_search_csv(self): - result = self.app.post('/search', data={'q': 'test', 'format': 'csv'}) - - self.assertEqual( - b'title,url,content,host,engine,score,type\r\n' - b'First Test,http://first.test.xyz,first test content,first.test.xyz,startpage,,result\r\n' # noqa - b'Second Test,http://second.test.xyz,second test content,second.test.xyz,youtube,,result\r\n', # noqa - result.data - ) - + def test_index_rss(self): result = self.app.post('/', data={'q': 'test', 'format': 'rss'}) self.assertEqual(result.status_code, 308) -- GitLab From 03325b3aef2cd852534d3d770e6f771bd5256201 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 15 Sep 2022 16:06:53 +0530 Subject: [PATCH 4/4] fix pep8 --- tests/unit/test_webapp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index f0faa815a..e67093d89 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import json from urllib.parse import ParseResult from mock import Mock from searx.testing import SearxTestCase @@ -116,7 +115,6 @@ class ViewsTestCase(SearxTestCase): result.data ) - def test_index_rss(self): result = self.app.post('/', data={'q': 'test', 'format': 'rss'}) self.assertEqual(result.status_code, 308) -- GitLab