forked from zaclys/searxng
[mod] yacy: use official instance by default and fix crashes
This commit is contained in:
parent
c2f26a560a
commit
16ce63b8a2
|
@ -18,17 +18,27 @@ Configuration
|
||||||
|
|
||||||
The engine has the following (additional) settings:
|
The engine has the following (additional) settings:
|
||||||
|
|
||||||
|
- :py:obj:`http_digest_auth_user`
|
||||||
|
- :py:obj:`http_digest_auth_pass`
|
||||||
|
- :py:obj:`search_mode`
|
||||||
|
- :py:obj:`search_type`
|
||||||
|
|
||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
|
||||||
- name: yacy
|
- name: yacy
|
||||||
engine: yacy
|
engine: yacy
|
||||||
|
categories: general
|
||||||
|
search_type: text
|
||||||
|
base_url: https://yacy.searchlab.eu
|
||||||
shortcut: ya
|
shortcut: ya
|
||||||
base_url: http://localhost:8090
|
|
||||||
# Yacy search mode. 'global' or 'local'.
|
- name: yacy images
|
||||||
search_mode: 'global'
|
engine: yacy
|
||||||
number_of_results: 5
|
categories: images
|
||||||
http_digest_auth_user: ""
|
search_type: image
|
||||||
http_digest_auth_pass: ""
|
base_url: https://yacy.searchlab.eu
|
||||||
|
shortcut: yai
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
|
||||||
Implementations
|
Implementations
|
||||||
|
@ -55,11 +65,14 @@ about = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ['general', 'images'] # TODO , 'music', 'videos', 'files'
|
categories = ['general']
|
||||||
paging = True
|
paging = True
|
||||||
number_of_results = 5
|
number_of_results = 10
|
||||||
http_digest_auth_user = ""
|
http_digest_auth_user = ""
|
||||||
|
"""HTTP digest user for the local YACY instance"""
|
||||||
http_digest_auth_pass = ""
|
http_digest_auth_pass = ""
|
||||||
|
"""HTTP digest password for the local YACY instance"""
|
||||||
|
|
||||||
search_mode = 'global'
|
search_mode = 'global'
|
||||||
"""Yacy search mode ``global`` or ``local``. By default, Yacy operates in ``global``
|
"""Yacy search mode ``global`` or ``local``. By default, Yacy operates in ``global``
|
||||||
mode.
|
mode.
|
||||||
|
@ -70,8 +83,13 @@ mode.
|
||||||
``local``
|
``local``
|
||||||
Privacy or Stealth mode, restricts the search to local yacy instance.
|
Privacy or Stealth mode, restricts the search to local yacy instance.
|
||||||
"""
|
"""
|
||||||
|
search_type = 'text'
|
||||||
|
"""One of ``text``, ``image`` / The search-types ``app``, ``audio`` and
|
||||||
|
``video`` are not yet implemented (Pull-Requests are welcome).
|
||||||
|
"""
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
base_url = 'http://localhost:8090'
|
base_url = 'https://yacy.searchlab.eu'
|
||||||
search_url = (
|
search_url = (
|
||||||
'/yacysearch.json?{query}'
|
'/yacysearch.json?{query}'
|
||||||
'&startRecord={offset}'
|
'&startRecord={offset}'
|
||||||
|
@ -80,13 +98,19 @@ search_url = (
|
||||||
'&resource={resource}'
|
'&resource={resource}'
|
||||||
)
|
)
|
||||||
|
|
||||||
# yacy specific type-definitions
|
|
||||||
search_types = {'general': 'text', 'images': 'image', 'files': 'app', 'music': 'audio', 'videos': 'video'}
|
def init(_):
|
||||||
|
valid_types = [
|
||||||
|
'text',
|
||||||
|
'image',
|
||||||
|
# 'app', 'audio', 'video',
|
||||||
|
]
|
||||||
|
if search_type not in valid_types:
|
||||||
|
raise ValueError('search_type "%s" is not one of %s' % (search_type, valid_types))
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
offset = (params['pageno'] - 1) * number_of_results
|
offset = (params['pageno'] - 1) * number_of_results
|
||||||
search_type = search_types.get(params.get('category'), '0')
|
|
||||||
|
|
||||||
params['url'] = base_url + search_url.format(
|
params['url'] = base_url + search_url.format(
|
||||||
query=urlencode({'query': query}),
|
query=urlencode({'query': query}),
|
||||||
|
@ -122,7 +146,7 @@ def response(resp):
|
||||||
|
|
||||||
for result in search_results[0].get('items', []):
|
for result in search_results[0].get('items', []):
|
||||||
# parse image results
|
# parse image results
|
||||||
if resp.search_params.get('category') == 'images':
|
if search_type == 'image':
|
||||||
result_url = ''
|
result_url = ''
|
||||||
if 'url' in result:
|
if 'url' in result:
|
||||||
result_url = result['url']
|
result_url = result['url']
|
||||||
|
@ -144,12 +168,14 @@ def response(resp):
|
||||||
|
|
||||||
# parse general results
|
# parse general results
|
||||||
else:
|
else:
|
||||||
|
publishedDate = None
|
||||||
|
if 'pubDate' in result:
|
||||||
publishedDate = parser.parse(result['pubDate'])
|
publishedDate = parser.parse(result['pubDate'])
|
||||||
|
|
||||||
# append result
|
# append result
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
'url': result['link'],
|
'url': result['link'] or '',
|
||||||
'title': result['title'],
|
'title': result['title'],
|
||||||
'content': html_to_text(result['description']),
|
'content': html_to_text(result['description']),
|
||||||
'publishedDate': publishedDate,
|
'publishedDate': publishedDate,
|
||||||
|
|
|
@ -1898,16 +1898,27 @@ engines:
|
||||||
shortcut: mvw
|
shortcut: mvw
|
||||||
disabled: true
|
disabled: true
|
||||||
|
|
||||||
# - name: yacy
|
- name: yacy
|
||||||
# engine: yacy
|
engine: yacy
|
||||||
# shortcut: ya
|
categories: general
|
||||||
# base_url: http://localhost:8090
|
search_type: text
|
||||||
# # required if you aren't using HTTPS for your local yacy instance'
|
base_url: https://yacy.searchlab.eu
|
||||||
|
shortcut: ya
|
||||||
|
disabled: true
|
||||||
|
# required if you aren't using HTTPS for your local yacy instance
|
||||||
|
# https://docs.searxng.org/dev/engines/online/yacy.html
|
||||||
# enable_http: true
|
# enable_http: true
|
||||||
# timeout: 3.0
|
# timeout: 3.0
|
||||||
# # Yacy search mode. 'global' or 'local'.
|
|
||||||
# search_mode: 'global'
|
# search_mode: 'global'
|
||||||
|
|
||||||
|
- name: yacy images
|
||||||
|
engine: yacy
|
||||||
|
categories: images
|
||||||
|
search_type: image
|
||||||
|
base_url: https://yacy.searchlab.eu
|
||||||
|
shortcut: yai
|
||||||
|
disabled: true
|
||||||
|
|
||||||
- name: rumble
|
- name: rumble
|
||||||
engine: rumble
|
engine: rumble
|
||||||
shortcut: ru
|
shortcut: ru
|
||||||
|
|
Loading…
Reference in New Issue