summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorSylvain Cau <ashdevfr@gmail.com>2024-07-23 16:07:38 -0700
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-07-27 09:21:40 +0200
commitb9ddd59c5b7daeabe4041d0e446a6572ba499942 (patch)
treeab3cb8fa186f18de1fe12928cc051a911bb9907a /searx
parentdde94751d6b315e1774284977676ab700b70400d (diff)
downloadsearxng-b9ddd59c5b7daeabe4041d0e446a6572ba499942.tar.gz
searxng-b9ddd59c5b7daeabe4041d0e446a6572ba499942.zip
[enh] Add API Key support for discourse.org forums
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/discourse.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/searx/engines/discourse.py b/searx/engines/discourse.py
index 298dd7ccf..97f4ef0cf 100644
--- a/searx/engines/discourse.py
+++ b/searx/engines/discourse.py
@@ -10,6 +10,8 @@ engine offers some additional settings:
- :py:obj:`api_order`
- :py:obj:`search_endpoint`
- :py:obj:`show_avatar`
+- :py:obj:`api_key`
+- :py:obj:`api_username`
Example
=======
@@ -27,6 +29,20 @@ for the ``paddling.com`` forum:
categories: ['social media', 'sports']
show_avatar: true
+If the forum is private, you need to add an API key and username for the search:
+
+.. code:: yaml
+
+ - name: paddling
+ engine: discourse
+ shortcut: paddle
+ base_url: 'https://forums.paddling.com/'
+ api_order: views
+ categories: ['social media', 'sports']
+ show_avatar: true
+ api_key: '<KEY>'
+ api_username: 'system'
+
Implementations
===============
@@ -65,6 +81,12 @@ api_order = 'likes'
show_avatar = False
"""Show avatar of the user who send the post."""
+api_key = ''
+"""API key of the Discourse forum."""
+
+api_username = ''
+"""API username of the Discourse forum."""
+
paging = True
time_range_support = True
@@ -98,6 +120,12 @@ def request(query, params):
'X-Requested-With': 'XMLHttpRequest',
}
+ if api_key != '':
+ params['headers']['Api-Key'] = api_key
+
+ if api_username != '':
+ params['headers']['Api-Username'] = api_username
+
return params