From 2fab23ab9a9288fb2ca4e9fb094075410b0995d3 Mon Sep 17 00:00:00 2001 From: Dalf Date: Fri, 26 Jul 2019 08:49:47 +0200 Subject: [PATCH 1/5] [fix] fix the debug message "starting webserver on ip:port" was "port:ip" --- searx/webapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/webapp.py b/searx/webapp.py index 856b013af..ee445e6f7 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -916,7 +916,7 @@ def page_not_found(e): def run(): - logger.debug('starting webserver on %s:%s', settings['server']['port'], settings['server']['bind_address']) + logger.debug('starting webserver on %s:%s', settings['server']['bind_address'], settings['server']['port']) app.run( debug=searx_debug, use_debugger=searx_debug, From 7d8000d9654f9fa9a051a5feceba2b429ea23a08 Mon Sep 17 00:00:00 2001 From: Dalf Date: Fri, 26 Jul 2019 08:51:04 +0200 Subject: [PATCH 2/5] [fix] "!wp !wp test" send only one request to wikipedia. Note that "!general !wp test" is not fixed because the category for "!wp" is "none". --- searx/search.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/searx/search.py b/searx/search.py index 465b5ce64..1472073bd 100644 --- a/searx/search.py +++ b/searx/search.py @@ -198,6 +198,13 @@ def default_request_params(): } +# remove duplicate queries. +# FIXME: does not fix "!music !soundcloud", because the categories are 'none' and 'music' +def deduplicate_query_engines(query_engines): + uniq_query_engines = {q["category"] + '|' + q["name"]: q for q in query_engines} + return uniq_query_engines.values() + + def get_search_query_from_webapp(preferences, form): # no text for the query ? if not form.get('q'): @@ -328,6 +335,8 @@ def get_search_query_from_webapp(preferences, form): for engine in categories[categ] if (engine.name, categ) not in disabled_engines) + query_engines = deduplicate_query_engines(query_engines) + return (SearchQuery(query, query_engines, query_categories, query_lang, query_safesearch, query_pageno, query_time_range), raw_text_query) From 8645ef717ea57dd037d538d37f026a5e6cf0cae0 Mon Sep 17 00:00:00 2001 From: Dalf Date: Fri, 26 Jul 2019 08:52:48 +0200 Subject: [PATCH 3/5] [fix] settings.yml: make sure all engine names are lower case --- searx/settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/settings.yml b/searx/settings.yml index bee7aed7e..bdf9e6c33 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -707,7 +707,7 @@ engines: shortcut : 1337x disabled : True - - name : Duden + - name : duden engine : duden shortcut : du disabled : True From 23611897ec2c7ff7f930ff6608eaa25d0fb27ca6 Mon Sep 17 00:00:00 2001 From: Dalf Date: Fri, 26 Jul 2019 09:04:00 +0200 Subject: [PATCH 4/5] [fix] make sure then engine name is lower case Minor fix: "%s engine initialized" display the right engine name --- searx/engines/__init__.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index f32b57202..a10b1ccd9 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -57,11 +57,16 @@ engine_default_args = {'paging': False, def load_engine(engine_data): - - if '_' in engine_data['name']: - logger.error('Engine name conains underscore: "{}"'.format(engine_data['name'])) + engine_name = engine_data['name'] + if '_' in engine_name: + logger.error('Engine name contains underscore: "{}"'.format(engine_name)) sys.exit(1) + if engine_name.lower() != engine_name: + logger.warn('Engine name is not lowercase: "{}", converting to lowercase'.format(engine_name)) + engine_name = engine_name.lower() + engine_data['name'] = engine_name + engine_module = engine_data['engine'] try: @@ -248,12 +253,14 @@ def load_engines(engine_list): def initialize_engines(engine_list): load_engines(engine_list) + + def engine_init(engine_name, init_fn): + init_fn() + logger.debug('%s engine: Initialized', engine_name) + for engine_name, engine in engines.items(): if hasattr(engine, 'init'): init_fn = getattr(engine, 'init') - - def engine_init(): - init_fn() - logger.debug('%s engine initialized', engine_name) - logger.debug('Starting background initialization of %s engine', engine_name) - threading.Thread(target=engine_init).start() + if init_fn: + logger.debug('%s engine: Starting background initialization', engine_name) + threading.Thread(target=engine_init, args=(engine_name, init_fn)).start() From 70a01e5f024c8845d6ee049c4d0ebd1bf73625ea Mon Sep 17 00:00:00 2001 From: Dalf Date: Sat, 27 Jul 2019 08:35:21 +0200 Subject: [PATCH 5/5] [fix] don't merge image results if the img_src is different --- searx/results.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/searx/results.py b/searx/results.py index d3f2ecd0d..be74a836b 100644 --- a/searx/results.py +++ b/searx/results.py @@ -212,11 +212,20 @@ class ResultContainer(object): # check for duplicates duplicated = False + result_template = result.get('template') for merged_result in self._merged_results: if compare_urls(result['parsed_url'], merged_result['parsed_url'])\ - and result.get('template') == merged_result.get('template'): - duplicated = merged_result - break + and result_template == merged_result.get('template'): + if result_template != 'images.html': + # not an image, same template, same url : it's a duplicate + duplicated = merged_result + break + else: + # it's an image + # it's a duplicate if the parsed_url, template and img_src are differents + if result.get('img_src', '') == merged_result.get('img_src', ''): + duplicated = merged_result + break # merge duplicates together if duplicated: