From 7d8000d9654f9fa9a051a5feceba2b429ea23a08 Mon Sep 17 00:00:00 2001 From: Dalf Date: Fri, 26 Jul 2019 08:51:04 +0200 Subject: [PATCH] [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)