merge functionalities into one engine

This commit is contained in:
Emilien Devos 2023-09-17 21:32:52 +02:00
parent 299a3fc7b0
commit 915e1399f0
3 changed files with 10 additions and 25 deletions

View File

@ -31,7 +31,7 @@ if TYPE_CHECKING:
traits: EngineTraits
display_type = "list"
display_type = ["infobox"]
# about
about = {
@ -270,7 +270,7 @@ def get_results(attribute_result, attributes, language):
for url in value.split(', '):
infobox_urls.append({'title': attribute.get_label(language), 'url': url, **attribute.kwargs})
# "normal" results (not infobox) include official website and Wikipedia links.
if display_type == "list" and (attribute.kwargs.get('official') or attribute_type == WDArticle):
if "infobox" in display_type and (attribute.kwargs.get('official') or attribute_type == WDArticle):
results.append({'title': infobox_title, 'url': url, "content": infobox_content})
# update the infobox_id with the wikipedia URL
# first the local wikipedia URL, and as fallback the english wikipedia URL
@ -309,7 +309,7 @@ def get_results(attribute_result, attributes, language):
if img_src is None and len(infobox_attributes) == 0 and len(infobox_urls) == 1 and len(infobox_content) == 0:
results.append({'url': infobox_urls[0]['url'], 'title': infobox_title, 'content': infobox_content})
elif display_type == "infobox":
elif "infobox" in display_type:
results.append(
{
'infobox': infobox_title,

View File

@ -67,7 +67,7 @@ from searx.enginelib.traits import EngineTraits
traits: EngineTraits
display_type = "list"
display_type = ["infobox"]
# about
about = {
@ -188,10 +188,10 @@ def response(resp):
title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
wikipedia_link = api_result['content_urls']['desktop']['page']
if display_type == "list":
if "list" in display_type:
results.append({'url': wikipedia_link, 'title': title, 'content': api_result.get('description', '')})
if display_type == "infobox":
if "infobox" in display_type:
if api_result.get('type') == 'standard':
results.append(
{

View File

@ -369,15 +369,8 @@ engines:
- name: wikipedia
engine: wikipedia
shortcut: wp
display_type: "list"
base_url: 'https://{language}.wikipedia.org/'
categories: [general]
disabled: true
- name: wikipedia.infobox
engine: wikipedia
shortcut: wpi
display_type: "infobox"
# add "list" to the array to get results in the results list
display_type: ["infobox"]
base_url: 'https://{language}.wikipedia.org/'
categories: [general]
@ -592,17 +585,9 @@ engines:
shortcut: wd
timeout: 3.0
weight: 2
display_type: "list"
# add "list" to the array to get results in the results list
display_type: ["infobox"]
tests: *tests_infobox
disabled: true
categories: [general]
- name: wikidata.infobox
engine: wikidata
timeout: 3.0
shortcut: wdi
weight: 2
display_type: "infobox"
categories: [general]
- name: duckduckgo