summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2023-10-05 17:37:59 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-11-27 16:46:41 +0100
commitbf75a8c2a0151faf258c0cc5f2210f42d7fe6e1f (patch)
tree26a75da1484b7e14029cf062c9b276e6cf52e15d
parent04cfce2eb845c0dfc7d578a6fb3c44cb546b2028 (diff)
[feat] engine: implementation of bpb
-rw-r--r--docs/dev/engines/online/bpb.rst13
-rw-r--r--searx/engines/bpb.py68
-rw-r--r--searx/settings.yml5
-rw-r--r--utils/brand.env4
4 files changed, 88 insertions, 2 deletions
diff --git a/docs/dev/engines/online/bpb.rst b/docs/dev/engines/online/bpb.rst
new file mode 100644
index 00000000..f545dba4
--- /dev/null
+++ b/docs/dev/engines/online/bpb.rst
@@ -0,0 +1,13 @@
+.. _bpb engine:
+
+===
+Bpb
+===
+
+.. contents:: Contents
+ :depth: 2
+ :local:
+ :backlinks: entry
+
+.. automodule:: searx.engines.bpb
+ :members:
diff --git a/searx/engines/bpb.py b/searx/engines/bpb.py
new file mode 100644
index 00000000..5d6359aa
--- /dev/null
+++ b/searx/engines/bpb.py
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# lint: pylint
+"""BPB refers to ``Bundeszentrale für poltische Bildung``, which is a German
+governmental institution aiming to reduce misinformation by providing resources
+about politics and history.
+"""
+
+from datetime import datetime
+from urllib.parse import urlencode
+
+about = {
+ 'website': "https://www.bpb.de",
+ 'official_api_documentation': None,
+ 'use_official_api': False,
+ 'require_api_key': False,
+ 'results': 'JSON',
+ 'language': 'de',
+}
+
+paging = True
+categories = ['general']
+
+
+base_url = "https://www.bpb.de"
+
+
+def request(query, params):
+ args = {
+ 'query[term]': query,
+ 'page': params['pageno'] - 1,
+ 'sort[direction]': 'descending',
+ 'payload[nid]': 65350,
+ }
+ params['url'] = f"{base_url}/bpbapi/filter/search?{urlencode(args)}"
+ return params
+
+
+def response(resp):
+ results = []
+
+ json_resp = resp.json()
+
+ for result in json_resp['teaser']:
+ img_src = None
+ if result['teaser']['image']:
+ img_src = base_url + result['teaser']['image']['sources'][-1]['url']
+
+ metadata = result['extension']['overline']
+ authors = ', '.join(author['name'] for author in result['extension'].get('authors', []))
+ if authors:
+ metadata += f" | {authors}"
+
+ publishedDate = None
+ if result['extension'].get('publishingDate'):
+ publishedDate = datetime.utcfromtimestamp(result['extension']['publishingDate'])
+
+ results.append(
+ {
+ 'url': base_url + result['teaser']['link']['url'],
+ 'title': result['teaser']['title'],
+ 'content': result['teaser']['text'],
+ 'img_src': img_src,
+ 'publishedDate': publishedDate,
+ 'metadata': metadata,
+ }
+ )
+
+ return results
diff --git a/searx/settings.yml b/searx/settings.yml
index 1e9f0855..926cddb5 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -419,6 +419,11 @@ engines:
require_api_key: false
results: HTML
+ - name: bpb
+ engine: bpb
+ shortcut: bpb
+ disabled: true
+
- name: btdigg
engine: btdigg
shortcut: bt
diff --git a/utils/brand.env b/utils/brand.env
index 31afce53..55531a4a 100644
--- a/utils/brand.env
+++ b/utils/brand.env
@@ -1,5 +1,5 @@
export SEARXNG_URL=''
export SEARXNG_PORT='8888'
export SEARXNG_BIND_ADDRESS='127.0.0.1'
-export GIT_URL='https://github.com/searxng/searxng'
-export GIT_BRANCH='master'
+export GIT_URL='https://github.com//Bnyro/searxng'
+export GIT_BRANCH='bpb'