mirror of
https://github.com/searx/searx
synced 2025-03-01 10:07:42 +01:00
[enh] add omnom engine
This commit is contained in:
parent
1abecbc835
commit
2222caec22
55
searx/engines/omnom.py
Normal file
55
searx/engines/omnom.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""
|
||||||
|
Omnom (General)
|
||||||
|
"""
|
||||||
|
|
||||||
|
from json import loads
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
# about
|
||||||
|
about = {
|
||||||
|
"website": 'https://github.com/asciimoo/omnom',
|
||||||
|
"wikidata_id": None,
|
||||||
|
"official_api_documentation": 'http://your.omnom.host/api',
|
||||||
|
"use_official_api": True,
|
||||||
|
"require_api_key": False,
|
||||||
|
"results": 'JSON',
|
||||||
|
}
|
||||||
|
|
||||||
|
# engine dependent config
|
||||||
|
categories = ['general']
|
||||||
|
paging = True
|
||||||
|
|
||||||
|
# search-url
|
||||||
|
base_url = None
|
||||||
|
search_path = 'bookmarks?{query}&pageno={pageno}&format=json'
|
||||||
|
bookmark_path = 'bookmark?id='
|
||||||
|
|
||||||
|
|
||||||
|
# do search-request
|
||||||
|
def request(query, params):
|
||||||
|
params['url'] = base_url +\
|
||||||
|
search_path.format(query=urlencode({'query': query}),
|
||||||
|
pageno=params['pageno'])
|
||||||
|
|
||||||
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
# get response from search-request
|
||||||
|
def response(resp):
|
||||||
|
results = []
|
||||||
|
json = loads(resp.text)
|
||||||
|
|
||||||
|
# parse results
|
||||||
|
for r in json.get('Bookmarks', {}):
|
||||||
|
content = r['url']
|
||||||
|
if r.get('notes'):
|
||||||
|
content += ' - ' + r['notes']
|
||||||
|
results.append({
|
||||||
|
'title': r['title'],
|
||||||
|
'content': content,
|
||||||
|
'url': base_url + bookmark_path + str(r['id']),
|
||||||
|
})
|
||||||
|
|
||||||
|
# return results
|
||||||
|
return results
|
@ -1684,6 +1684,15 @@ engines:
|
|||||||
require_api_key: false
|
require_api_key: false
|
||||||
results: HTML
|
results: HTML
|
||||||
|
|
||||||
|
# omnom engine - see https://github.com/asciimoo/omnom for more details
|
||||||
|
# - name : omnom
|
||||||
|
# engine : omnom
|
||||||
|
# paging : True
|
||||||
|
# base_url : 'http://your.omnom.host/'
|
||||||
|
# enable_http : True
|
||||||
|
# categories : general
|
||||||
|
# shortcut : om
|
||||||
|
|
||||||
# Doku engine lets you access to any Doku wiki instance:
|
# Doku engine lets you access to any Doku wiki instance:
|
||||||
# A public one or a private/corporate one.
|
# A public one or a private/corporate one.
|
||||||
# - name : ubuntuwiki
|
# - name : ubuntuwiki
|
||||||
|
Loading…
x
Reference in New Issue
Block a user