summaryrefslogtreecommitdiff
path: root/searx/results.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2016-06-27 23:35:43 -0500
committermarc <a01200356@itesm.mx>2016-08-05 23:51:04 -0500
commitad58b14be7cc9a1e95858e150e9d8005734d9232 (patch)
treea28f875b0c79183ddc572bd4a5aa3d93f30937f8 /searx/results.py
parentc2e40142879fcb08291471f0306a793fce63c124 (diff)
[fix] merge infoboxes based on weight
also minor changes in attributes and images from wikidata
Diffstat (limited to 'searx/results.py')
-rw-r--r--searx/results.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/searx/results.py b/searx/results.py
index bf4067b4..9a4ec0b2 100644
--- a/searx/results.py
+++ b/searx/results.py
@@ -43,6 +43,19 @@ def compare_urls(url_a, url_b):
def merge_two_infoboxes(infobox1, infobox2):
+ # get engines weights
+ if hasattr(engines[infobox1['engine']], 'weight'):
+ weight1 = engines[infobox1['engine']].weight
+ else:
+ weight1 = 1
+ if hasattr(engines[infobox2['engine']], 'weight'):
+ weight2 = engines[infobox2['engine']].weight
+ else:
+ weight2 = 1
+
+ if weight2 > weight1:
+ infobox1['engine'] = infobox2['engine']
+
if 'urls' in infobox2:
urls1 = infobox1.get('urls', None)
if urls1 is None:
@@ -64,6 +77,8 @@ def merge_two_infoboxes(infobox1, infobox2):
img2 = infobox2.get('img_src')
if img1 is None:
infobox1['img_src'] = img2
+ elif weight2 > weight1:
+ infobox1['img_src'] = img2
if 'attributes' in infobox2:
attributes1 = infobox1.get('attributes', None)
@@ -77,7 +92,8 @@ def merge_two_infoboxes(infobox1, infobox2):
attributeSet.add(attribute.get('label', None))
for attribute in infobox2.get('attributes', []):
- attributes1.append(attribute)
+ if attribute.get('label', None) not in attributeSet:
+ attributes1.append(attribute)
if 'content' in infobox2:
content1 = infobox1.get('content', None)