summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-02-11 15:11:26 +0100
committerGitHub <noreply@github.com>2021-02-11 15:11:26 +0100
commit74c8b5606f9bfd4a6a4c36b2d0e789b223f82c6a (patch)
tree1421ffc608ba6c318348339da1bb5fffcf782678
parent436d366448131088a9cddcedc9b789a44b38ee97 (diff)
parentbc1be3f0e9df3e634e3193db1f052a75bbb4e682 (diff)
downloadsearxng-74c8b5606f9bfd4a6a4c36b2d0e789b223f82c6a.tar.gz
searxng-74c8b5606f9bfd4a6a4c36b2d0e789b223f82c6a.zip
Merge pull request #2541 from return42/mediathekviewweb
[enh] add engine MediathekViewWeb (API)
-rw-r--r--Makefile3
-rw-r--r--searx/engines/mediathekviewweb.py68
-rw-r--r--searx/settings.yml4
3 files changed, 74 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index d148581dd..13f965b6c 100644
--- a/Makefile
+++ b/Makefile
@@ -193,7 +193,8 @@ PYLINT_FILES=\
searx/engines/google.py \
searx/engines/google_news.py \
searx/engines/google_videos.py \
- searx/engines/google_images.py
+ searx/engines/google_images.py \
+ searx/engines/mediathekviewweb.py
test.pylint: pyenvinstall
$(call cmd,pylint,$(PYLINT_FILES))
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
diff --git a/searx/settings.yml b/searx/settings.yml
index 20b6c18c1..87008eb20 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -1258,6 +1258,10 @@ engines:
categories: videos
disabled : True
+ - name : mediathekviewweb
+ engine : mediathekviewweb
+ shortcut : mvw
+
# - name : yacy
# engine : yacy
# shortcut : ya