merge functionalities into one engine
This commit is contained in:
parent
299a3fc7b0
commit
915e1399f0
@ -31,7 +31,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
traits: EngineTraits
|
traits: EngineTraits
|
||||||
|
|
||||||
display_type = "list"
|
display_type = ["infobox"]
|
||||||
|
|
||||||
# about
|
# about
|
||||||
about = {
|
about = {
|
||||||
@ -270,7 +270,7 @@ def get_results(attribute_result, attributes, language):
|
|||||||
for url in value.split(', '):
|
for url in value.split(', '):
|
||||||
infobox_urls.append({'title': attribute.get_label(language), 'url': url, **attribute.kwargs})
|
infobox_urls.append({'title': attribute.get_label(language), 'url': url, **attribute.kwargs})
|
||||||
# "normal" results (not infobox) include official website and Wikipedia links.
|
# "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})
|
results.append({'title': infobox_title, 'url': url, "content": infobox_content})
|
||||||
# update the infobox_id with the wikipedia URL
|
# update the infobox_id with the wikipedia URL
|
||||||
# first the local wikipedia URL, and as fallback the english 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:
|
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})
|
results.append({'url': infobox_urls[0]['url'], 'title': infobox_title, 'content': infobox_content})
|
||||||
elif display_type == "infobox":
|
elif "infobox" in display_type:
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
'infobox': infobox_title,
|
'infobox': infobox_title,
|
||||||
|
@ -67,7 +67,7 @@ from searx.enginelib.traits import EngineTraits
|
|||||||
|
|
||||||
traits: EngineTraits
|
traits: EngineTraits
|
||||||
|
|
||||||
display_type = "list"
|
display_type = ["infobox"]
|
||||||
|
|
||||||
# about
|
# about
|
||||||
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'))
|
title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
|
||||||
wikipedia_link = api_result['content_urls']['desktop']['page']
|
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', '')})
|
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':
|
if api_result.get('type') == 'standard':
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
|
@ -369,15 +369,8 @@ engines:
|
|||||||
- name: wikipedia
|
- name: wikipedia
|
||||||
engine: wikipedia
|
engine: wikipedia
|
||||||
shortcut: wp
|
shortcut: wp
|
||||||
display_type: "list"
|
# add "list" to the array to get results in the results list
|
||||||
base_url: 'https://{language}.wikipedia.org/'
|
display_type: ["infobox"]
|
||||||
categories: [general]
|
|
||||||
disabled: true
|
|
||||||
|
|
||||||
- name: wikipedia.infobox
|
|
||||||
engine: wikipedia
|
|
||||||
shortcut: wpi
|
|
||||||
display_type: "infobox"
|
|
||||||
base_url: 'https://{language}.wikipedia.org/'
|
base_url: 'https://{language}.wikipedia.org/'
|
||||||
categories: [general]
|
categories: [general]
|
||||||
|
|
||||||
@ -592,17 +585,9 @@ engines:
|
|||||||
shortcut: wd
|
shortcut: wd
|
||||||
timeout: 3.0
|
timeout: 3.0
|
||||||
weight: 2
|
weight: 2
|
||||||
display_type: "list"
|
# add "list" to the array to get results in the results list
|
||||||
|
display_type: ["infobox"]
|
||||||
tests: *tests_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]
|
categories: [general]
|
||||||
|
|
||||||
- name: duckduckgo
|
- name: duckduckgo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user