mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 20:17:45 +01:00
commit
4b56a4bfaa
@ -57,11 +57,16 @@ engine_default_args = {'paging': False,
|
|||||||
|
|
||||||
|
|
||||||
def load_engine(engine_data):
|
def load_engine(engine_data):
|
||||||
|
engine_name = engine_data['name']
|
||||||
if '_' in engine_data['name']:
|
if '_' in engine_name:
|
||||||
logger.error('Engine name conains underscore: "{}"'.format(engine_data['name']))
|
logger.error('Engine name contains underscore: "{}"'.format(engine_name))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if engine_name.lower() != engine_name:
|
||||||
|
logger.warn('Engine name is not lowercase: "{}", converting to lowercase'.format(engine_name))
|
||||||
|
engine_name = engine_name.lower()
|
||||||
|
engine_data['name'] = engine_name
|
||||||
|
|
||||||
engine_module = engine_data['engine']
|
engine_module = engine_data['engine']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -248,12 +253,14 @@ def load_engines(engine_list):
|
|||||||
|
|
||||||
def initialize_engines(engine_list):
|
def initialize_engines(engine_list):
|
||||||
load_engines(engine_list)
|
load_engines(engine_list)
|
||||||
|
|
||||||
|
def engine_init(engine_name, init_fn):
|
||||||
|
init_fn()
|
||||||
|
logger.debug('%s engine: Initialized', engine_name)
|
||||||
|
|
||||||
for engine_name, engine in engines.items():
|
for engine_name, engine in engines.items():
|
||||||
if hasattr(engine, 'init'):
|
if hasattr(engine, 'init'):
|
||||||
init_fn = getattr(engine, 'init')
|
init_fn = getattr(engine, 'init')
|
||||||
|
if init_fn:
|
||||||
def engine_init():
|
logger.debug('%s engine: Starting background initialization', engine_name)
|
||||||
init_fn()
|
threading.Thread(target=engine_init, args=(engine_name, init_fn)).start()
|
||||||
logger.debug('%s engine initialized', engine_name)
|
|
||||||
logger.debug('Starting background initialization of %s engine', engine_name)
|
|
||||||
threading.Thread(target=engine_init).start()
|
|
||||||
|
@ -212,9 +212,18 @@ class ResultContainer(object):
|
|||||||
|
|
||||||
# check for duplicates
|
# check for duplicates
|
||||||
duplicated = False
|
duplicated = False
|
||||||
|
result_template = result.get('template')
|
||||||
for merged_result in self._merged_results:
|
for merged_result in self._merged_results:
|
||||||
if compare_urls(result['parsed_url'], merged_result['parsed_url'])\
|
if compare_urls(result['parsed_url'], merged_result['parsed_url'])\
|
||||||
and result.get('template') == merged_result.get('template'):
|
and result_template == merged_result.get('template'):
|
||||||
|
if result_template != 'images.html':
|
||||||
|
# not an image, same template, same url : it's a duplicate
|
||||||
|
duplicated = merged_result
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# it's an image
|
||||||
|
# it's a duplicate if the parsed_url, template and img_src are differents
|
||||||
|
if result.get('img_src', '') == merged_result.get('img_src', ''):
|
||||||
duplicated = merged_result
|
duplicated = merged_result
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -198,6 +198,13 @@ def default_request_params():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# remove duplicate queries.
|
||||||
|
# FIXME: does not fix "!music !soundcloud", because the categories are 'none' and 'music'
|
||||||
|
def deduplicate_query_engines(query_engines):
|
||||||
|
uniq_query_engines = {q["category"] + '|' + q["name"]: q for q in query_engines}
|
||||||
|
return uniq_query_engines.values()
|
||||||
|
|
||||||
|
|
||||||
def get_search_query_from_webapp(preferences, form):
|
def get_search_query_from_webapp(preferences, form):
|
||||||
# no text for the query ?
|
# no text for the query ?
|
||||||
if not form.get('q'):
|
if not form.get('q'):
|
||||||
@ -328,6 +335,8 @@ def get_search_query_from_webapp(preferences, form):
|
|||||||
for engine in categories[categ]
|
for engine in categories[categ]
|
||||||
if (engine.name, categ) not in disabled_engines)
|
if (engine.name, categ) not in disabled_engines)
|
||||||
|
|
||||||
|
query_engines = deduplicate_query_engines(query_engines)
|
||||||
|
|
||||||
return (SearchQuery(query, query_engines, query_categories,
|
return (SearchQuery(query, query_engines, query_categories,
|
||||||
query_lang, query_safesearch, query_pageno, query_time_range),
|
query_lang, query_safesearch, query_pageno, query_time_range),
|
||||||
raw_text_query)
|
raw_text_query)
|
||||||
|
@ -707,7 +707,7 @@ engines:
|
|||||||
shortcut : 1337x
|
shortcut : 1337x
|
||||||
disabled : True
|
disabled : True
|
||||||
|
|
||||||
- name : Duden
|
- name : duden
|
||||||
engine : duden
|
engine : duden
|
||||||
shortcut : du
|
shortcut : du
|
||||||
disabled : True
|
disabled : True
|
||||||
|
@ -916,7 +916,7 @@ def page_not_found(e):
|
|||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
logger.debug('starting webserver on %s:%s', settings['server']['port'], settings['server']['bind_address'])
|
logger.debug('starting webserver on %s:%s', settings['server']['bind_address'], settings['server']['port'])
|
||||||
app.run(
|
app.run(
|
||||||
debug=searx_debug,
|
debug=searx_debug,
|
||||||
use_debugger=searx_debug,
|
use_debugger=searx_debug,
|
||||||
|
Loading…
Reference in New Issue
Block a user