Commit db62af27 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Fix invalid type of engines during merge result

Engines was stored in set and casted in list, it leads to
issue during merge of result. This patch fixes the engines
container to a list to be able to use json serialization.

Below the error spotted:
   File "/usr/local/searx/searx/", line 233, in _merge_result
 AttributeError: 'list' object has no attribute 'add'
parent 0dde07cc
......@@ -203,14 +203,14 @@ class ResultContainer(object):
result['parsed_url'] = result['parsed_url']._replace(scheme="http")
result['url'] = result['parsed_url'].geturl()
result['engines'] = set([result['engine']])
result['engines'] = [result['engine']]
# strip multiple spaces and cariage returns from content
if result.get('content'):
result['content'] = WHITESPACE_REGEX.sub(' ', result['content'])
# check for duplicates
duplicated = False
duplicated = None
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'):
......@@ -233,7 +233,8 @@ class ResultContainer(object):
# add engine to list of result-engines
if result['engine'] not in duplicated['engines']:
# using https if possible
if duplicated['parsed_url'].scheme != 'https' and result['parsed_url'].scheme == 'https':
......@@ -118,9 +118,6 @@ def get_search_data(q, r):
results_number = 0
results = r.get_ordered_results()
for result in results:
result['engines'] = list(result['engines'])
if not type(result['engines']) is list:
if 'publishedDate' in result:
result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment