Browse Source

[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".
Dalf 5 years ago
parent
commit
7d8000d965
1 changed files with 9 additions and 0 deletions
  1. 9 0
      searx/search.py

+ 9 - 0
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)