mirror of
https://github.com/searxng/searxng.git
synced 2025-12-22 19:50:00 +00:00
Compare commits
3 Commits
5fcee9bc30
...
2313b972a3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2313b972a3 | ||
|
|
989b49335c | ||
|
|
3f30831640 |
@@ -270,7 +270,14 @@ def load_engines(engine_list: list[dict[str, t.Any]]):
|
|||||||
categories.clear()
|
categories.clear()
|
||||||
categories['general'] = []
|
categories['general'] = []
|
||||||
for engine_data in engine_list:
|
for engine_data in engine_list:
|
||||||
|
if engine_data.get("inactive") is True:
|
||||||
|
continue
|
||||||
engine = load_engine(engine_data)
|
engine = load_engine(engine_data)
|
||||||
if engine:
|
if engine:
|
||||||
register_engine(engine)
|
register_engine(engine)
|
||||||
|
else:
|
||||||
|
# if an engine can't be loaded (if for example the engine is missing
|
||||||
|
# tor or some other requirements) its set to inactive!
|
||||||
|
logger.error("loading engine %s failed: set engine to inactive!", engine_data.get("name", "???"))
|
||||||
|
engine_data["inactive"] = True
|
||||||
return engines
|
return engines
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ paging = True
|
|||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
|
||||||
# base_url can be overwritten by a list of URLs in the settings.yml
|
# base_url can be overwritten by a list of URLs in the settings.yml
|
||||||
base_url: list | str = []
|
base_url: list[str] | str = []
|
||||||
|
|
||||||
|
|
||||||
def init(_):
|
def init(_):
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ categories = []
|
|||||||
paging = True
|
paging = True
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
backend_url: list[str] | str | None = None
|
backend_url: list[str] | str = []
|
||||||
"""Piped-Backend_: The core component behind Piped. The value is an URL or a
|
"""Piped-Backend_: The core component behind Piped. The value is an URL or a
|
||||||
list of URLs. In the latter case instance will be selected randomly. For a
|
list of URLs. In the latter case instance will be selected randomly. For a
|
||||||
complete list of official instances see Piped-Instances (`JSON
|
complete list of official instances see Piped-Instances (`JSON
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ categories = ['images']
|
|||||||
|
|
||||||
# Search URL
|
# Search URL
|
||||||
base_url = "https://www.pixiv.net/ajax/search/illustrations"
|
base_url = "https://www.pixiv.net/ajax/search/illustrations"
|
||||||
pixiv_image_proxies: list = []
|
pixiv_image_proxies: list[str] = []
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ search_type = 'text'
|
|||||||
``video`` are not yet implemented (Pull-Requests are welcome).
|
``video`` are not yet implemented (Pull-Requests are welcome).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
base_url: list[str] | str | None = None
|
base_url: list[str] | str = []
|
||||||
"""The value is an URL or a list of URLs. In the latter case instance will be
|
"""The value is an URL or a list of URLs. In the latter case instance will be
|
||||||
selected randomly.
|
selected randomly.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from searx.network import initialize as initialize_network, check_network_config
|
|||||||
from searx.results import ResultContainer
|
from searx.results import ResultContainer
|
||||||
from searx.search.checker import initialize as initialize_checker
|
from searx.search.checker import initialize as initialize_checker
|
||||||
from searx.search.processors import PROCESSORS
|
from searx.search.processors import PROCESSORS
|
||||||
|
from searx.search.processors.abstract import RequestParams
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
from .models import SearchQuery
|
from .models import SearchQuery
|
||||||
@@ -79,16 +79,20 @@ class Search:
|
|||||||
return bool(results)
|
return bool(results)
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
def _get_requests(self) -> tuple[list[tuple[str, str, dict[str, t.Any]]], int]:
|
def _get_requests(self) -> tuple[list[tuple[str, str, RequestParams]], float]:
|
||||||
# init vars
|
# init vars
|
||||||
requests: list[tuple[str, str, dict[str, t.Any]]] = []
|
requests: list[tuple[str, str, RequestParams]] = []
|
||||||
|
|
||||||
# max of all selected engine timeout
|
# max of all selected engine timeout
|
||||||
default_timeout = 0
|
default_timeout = 0
|
||||||
|
|
||||||
# start search-request for all selected engines
|
# start search-request for all selected engines
|
||||||
for engineref in self.search_query.engineref_list:
|
for engineref in self.search_query.engineref_list:
|
||||||
processor = PROCESSORS[engineref.name]
|
processor = PROCESSORS.get(engineref.name)
|
||||||
|
if not processor:
|
||||||
|
# engine does not exists; not yet or the 'init' method of the
|
||||||
|
# engine has been failed and the engine has not been registered.
|
||||||
|
continue
|
||||||
|
|
||||||
# stop the request now if the engine is suspend
|
# stop the request now if the engine is suspend
|
||||||
if processor.extend_container_if_suspended(self.result_container):
|
if processor.extend_container_if_suspended(self.result_container):
|
||||||
@@ -133,7 +137,7 @@ class Search:
|
|||||||
|
|
||||||
return requests, actual_timeout
|
return requests, actual_timeout
|
||||||
|
|
||||||
def search_multiple_requests(self, requests: list[tuple[str, str, dict[str, t.Any]]]):
|
def search_multiple_requests(self, requests: list[tuple[str, str, RequestParams]]):
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
search_id = str(uuid4())
|
search_id = str(uuid4())
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ class ProcessorMap(dict[str, EngineProcessor]):
|
|||||||
eng_name: str = eng_settings["name"]
|
eng_name: str = eng_settings["name"]
|
||||||
|
|
||||||
if eng_settings.get("inactive", False) is True:
|
if eng_settings.get("inactive", False) is True:
|
||||||
logger.info("Engine of name '%s' is inactive.", eng_name)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
eng_obj = engines.engines.get(eng_name)
|
eng_obj = engines.engines.get(eng_name)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class TestEnginesInit(SearxTestCase):
|
|||||||
with self.assertLogs('searx.engines', level='ERROR') as cm: # pylint: disable=invalid-name
|
with self.assertLogs('searx.engines', level='ERROR') as cm: # pylint: disable=invalid-name
|
||||||
engines.load_engines(engine_list)
|
engines.load_engines(engine_list)
|
||||||
self.assertEqual(len(engines.engines), 0)
|
self.assertEqual(len(engines.engines), 0)
|
||||||
self.assertEqual(cm.output, ['ERROR:searx.engines:An engine does not have a "name" field'])
|
self.assertEqual(cm.output[0], 'ERROR:searx.engines:An engine does not have a "name" field')
|
||||||
|
|
||||||
def test_missing_engine_field(self):
|
def test_missing_engine_field(self):
|
||||||
settings['outgoing']['using_tor_proxy'] = False
|
settings['outgoing']['using_tor_proxy'] = False
|
||||||
@@ -72,5 +72,5 @@ class TestEnginesInit(SearxTestCase):
|
|||||||
engines.load_engines(engine_list)
|
engines.load_engines(engine_list)
|
||||||
self.assertEqual(len(engines.engines), 0)
|
self.assertEqual(len(engines.engines), 0)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
cm.output, ['ERROR:searx.engines:The "engine" field is missing for the engine named "engine2"']
|
cm.output[0], 'ERROR:searx.engines:The "engine" field is missing for the engine named "engine2"'
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user