.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
mrs.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Matrix Rooms Search - a fully-featured, standalone, matrix rooms search service.
3
4
Configuration
5
=============
6
7
The engine has the following mandatory settings:
8
9
- :py:obj:`base_url`
10
11
.. code:: yaml
12
13
- name: MRS
14
engine: mrs
15
base_url: https://mrs-host
16
...
17
18
Implementation
19
==============
20
"""
21
22
from
urllib.parse
import
quote_plus
23
24
about = {
25
"website"
:
'https://matrixrooms.info'
,
26
"wikidata_id"
:
None
,
27
"official_api_documentation"
:
'https://gitlab.com/etke.cc/mrs/api/-/blob/main/openapi.yml?ref_type=heads'
,
28
"use_official_api"
:
True
,
29
"require_api_key"
:
False
,
30
"results"
:
'JSON'
,
31
}
32
paging =
True
33
categories = [
'social media'
]
34
35
base_url =
""
36
matrix_url =
"https://matrix.to"
37
page_size = 20
38
39
40
def
init
(engine_settings):
# pylint: disable=unused-argument
41
"""The ``base_url`` must be set in the configuration, if ``base_url`` is not
42
set, a :py:obj:`ValueError` is raised during initialization.
43
44
"""
45
if
not
base_url:
46
raise
ValueError(
'engine MRS, base_url is unset'
)
47
48
49
def
request
(query, params):
50
params[
'url'
] = f
"{base_url}/search/{quote_plus(query)}/{page_size}/{(params['pageno']-1)*page_size}"
51
return
params
52
53
54
def
response
(resp):
55
results = []
56
57
for
result
in
resp.json():
58
results.append(
59
{
60
'url'
: matrix_url +
'/#/'
+ result[
'alias'
],
61
'title'
: result[
'name'
],
62
'content'
: result[
'topic'
]
63
+ f
" // {result['members']} members"
64
+ f
" // {result['alias']}"
65
+ f
" // {result['server']}"
,
66
'thumbnail'
: result[
'avatar_url'
],
67
}
68
)
69
70
return
results
searx.engines.mrs.response
response(resp)
Definition
mrs.py:54
searx.engines.mrs.init
init(engine_settings)
Definition
mrs.py:40
searx.engines.mrs.request
request(query, params)
Definition
mrs.py:49
searxng
searx
engines
mrs.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0