Fixing plugin not producing output
This commit is contained in:
+8
-9
@@ -7,7 +7,7 @@ except ImportError:
|
||||
get_network = None
|
||||
from flask import Response, request, abort, jsonify
|
||||
from searx.plugins import Plugin, PluginInfo
|
||||
from searx.result_types import EngineResults
|
||||
from searx.result_types import Answer
|
||||
from searx import settings
|
||||
from flask_babel import gettext
|
||||
from markupsafe import Markup
|
||||
@@ -630,23 +630,22 @@ class SXNGPlugin(Plugin):
|
||||
|
||||
return "\n\n".join(context_parts), result_urls
|
||||
|
||||
def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> EngineResults:
|
||||
results = EngineResults()
|
||||
def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> list:
|
||||
try:
|
||||
if request and hasattr(request, 'headers') and request.headers.get('X-AI-Auxiliary'):
|
||||
return results
|
||||
return []
|
||||
|
||||
if request and request.form.get('format', 'html') != 'html':
|
||||
return results
|
||||
return []
|
||||
|
||||
if self.question_mark_required and '?' not in search.search_query.query:
|
||||
return results
|
||||
return []
|
||||
|
||||
current_tabs = set(search.search_query.categories)
|
||||
if not current_tabs: current_tabs = {'general'}
|
||||
|
||||
if not self.active or not self.api_key or search.search_query.pageno > 1 or not self.allowed_tabs.intersection(current_tabs):
|
||||
return results
|
||||
return []
|
||||
|
||||
raw_results = search.result_container.get_ordered_results()
|
||||
raw_infoboxes = getattr(search.result_container, 'infoboxes', [])
|
||||
@@ -770,7 +769,7 @@ class SXNGPlugin(Plugin):
|
||||
</script>
|
||||
</article>
|
||||
'''
|
||||
search.result_container.answers.add(results.types.Answer(answer=Markup(html_payload)))
|
||||
return [Answer(answer=Markup(html_payload))]
|
||||
except Exception as e:
|
||||
logger.error(f"{PLUGIN_NAME}: {e}")
|
||||
return results
|
||||
return []
|
||||
Reference in New Issue
Block a user