summaryrefslogtreecommitdiff
path: root/searx/engines/mediathekviewweb.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2021-02-09 13:08:01 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2021-02-09 13:08:01 +0100
commitbc1be3f0e9df3e634e3193db1f052a75bbb4e682 (patch)
treef571d5862b3678172553c7c9cd024e3059d66457 /searx/engines/mediathekviewweb.py
parentab8739809c8c5f4c1f12e4b15fa8c61afe30ef9f (diff)
downloadsearxng-bc1be3f0e9df3e634e3193db1f052a75bbb4e682.tar.gz
searxng-bc1be3f0e9df3e634e3193db1f052a75bbb4e682.zip
[enh] add engine MediathekViewWeb (API)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/mediathekviewweb.py')
-rw-r--r--searx/engines/mediathekviewweb.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/searx/engines/mediathekviewweb.py b/searx/engines/mediathekviewweb.py
new file mode 100644
index 000000000..fa442c937
--- /dev/null
+++ b/searx/engines/mediathekviewweb.py
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+"""MediathekViewWeb (API)
+
+"""
+
+# pylint: disable=missing-function-docstring
+
+import datetime
+from json import loads, dumps
+
+about = {
+ "website": 'https://mediathekviewweb.de/',
+ "wikidata_id": 'Q27877380',
+ "official_api_documentation": 'https://gist.github.com/bagbag/a2888478d27de0e989cf777f81fb33de',
+ "use_official_api": True,
+ "require_api_key": False,
+ "results": 'JSON',
+}
+
+categories = ['videos']
+paging = True
+time_range_support = False
+safesearch = False
+
+def request(query, params):
+
+ params['url'] = 'https://mediathekviewweb.de/api/query'
+ params['method'] = 'POST'
+ params['headers']['Content-type'] = 'text/plain'
+ params['data'] = dumps({
+ 'queries' : [
+ {
+ 'fields' : [
+ 'title',
+ 'topic',
+ ],
+ 'query' : query
+ },
+ ],
+ 'sortBy' : 'timestamp',
+ 'sortOrder' : 'desc',
+ 'future' : True,
+ 'offset' : (params['pageno'] - 1 )* 10,
+ 'size' : 10
+ })
+ return params
+
+def response(resp):
+
+ resp = loads(resp.text)
+
+ mwv_result = resp['result']
+ mwv_result_list = mwv_result['results']
+
+ results = []
+
+ for item in mwv_result_list:
+
+ item['hms'] = str(datetime.timedelta(seconds=item['duration']))
+
+ results.append({
+ 'url' : item['url_video_hd'],
+ 'title' : "%(channel)s: %(title)s (%(hms)s)" % item,
+ 'length' : item['hms'],
+ 'content' : "%(description)s" % item,
+ })
+
+ return results