summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAine <aine@etke.cc>2023-10-08 23:27:43 +0300
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-10-09 13:25:13 +0200
commit213cb74378a02a0863c3028d6817751124c62183 (patch)
tree9db11fc1d9690637b15e38dcc9c3c08ac03b65e3
parent48cb58bd2ec4eb9cb4ba416f7ece75c3c6c41e55 (diff)
downloadsearxng-213cb74378a02a0863c3028d6817751124c62183.tar.gz
searxng-213cb74378a02a0863c3028d6817751124c62183.zip
[fix] matrixrooms add proper MRS integration
Related: - https://github.com/searxng/searxng/issues/2918
-rw-r--r--docs/dev/engines/online/mrs.rst13
-rw-r--r--searx/engines/mrs.py (renamed from searx/engines/matrixrooms.py)36
-rw-r--r--searx/settings.yml10
3 files changed, 50 insertions, 9 deletions
diff --git a/docs/dev/engines/online/mrs.rst b/docs/dev/engines/online/mrs.rst
new file mode 100644
index 000000000..671f35ea5
--- /dev/null
+++ b/docs/dev/engines/online/mrs.rst
@@ -0,0 +1,13 @@
+.. _mrs engine:
+
+=========================
+Matrix Rooms Search (MRS)
+=========================
+
+.. contents:: Contents
+ :depth: 2
+ :local:
+ :backlinks: entry
+
+.. automodule:: searx.engines.mrs
+ :members:
diff --git a/searx/engines/matrixrooms.py b/searx/engines/mrs.py
index 06c4d99a9..68e34d21d 100644
--- a/searx/engines/matrixrooms.py
+++ b/searx/engines/mrs.py
@@ -1,26 +1,52 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# lint: pylint
-"""Matrixrooms.info (social media)
+"""Matrix Rooms Search - a fully-featured, standalone, matrix rooms search service.
+
+Configuration
+=============
+
+The engine has the following mandatory settings:
+
+- :py:obj:`base_url`
+
+.. code:: yaml
+
+ - name: MRS
+ engine: mrs
+ base_url: https://mrs-host
+ ...
+
+Implementation
+==============
"""
from urllib.parse import quote_plus
about = {
"website": 'https://matrixrooms.info',
- "wikidata_id": 'Q107565255',
- "official_api_documentation": None,
- "use_official_api": False,
+ "wikidata_id": None,
+ "official_api_documentation": 'https://gitlab.com/etke.cc/mrs/api/-/blob/main/openapi.yml?ref_type=heads',
+ "use_official_api": True,
"require_api_key": False,
"results": 'JSON',
}
paging = True
categories = ['social media']
-base_url = "https://apicdn.matrixrooms.info"
+base_url = ""
matrix_url = "https://matrix.to"
page_size = 20
+def init(engine_settings): # pylint: disable=unused-argument
+ """The ``base_url`` must be set in the configuration, if ``base_url`` is not
+ set, a :py:obj:`ValueError` is raised during initialization.
+
+ """
+ if not base_url:
+ raise ValueError('engine MRS, base_url is unset')
+
+
def request(query, params):
params['url'] = f"{base_url}/search/{quote_plus(query)}/{page_size}/{(params['pageno']-1)*page_size}"
return params
diff --git a/searx/settings.yml b/searx/settings.yml
index 8b6d32301..a96199c0c 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -1043,10 +1043,12 @@ engines:
base_url: https://mastodon.social
shortcut: mah
- - name: matrixrooms
- engine: matrixrooms
- shortcut: mtrx
- disabled: true
+ # - name: matrixrooms
+ # engine: mrs
+ # # https://docs.searxng.org/dev/engines/online/mrs.html
+ # # base_url: https://mrs-api-host
+ # shortcut: mtrx
+ # disabled: true
- name: metacpan
engine: metacpan