2021-02-09 12:08:01 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2021-04-26 18:18:20 +00:00
|
|
|
# lint: pylint
|
2021-02-09 12:08:01 +00:00
|
|
|
"""MediathekViewWeb (API)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
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',
|
2021-12-21 08:39:03 +00:00
|
|
|
"language": "de",
|
2021-02-09 12:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
categories = ['videos']
|
|
|
|
paging = True
|
|
|
|
time_range_support = False
|
|
|
|
safesearch = False
|
|
|
|
|
2021-12-27 08:26:22 +00:00
|
|
|
|
2021-02-09 12:08:01 +00:00
|
|
|
def request(query, params):
|
|
|
|
|
|
|
|
params['url'] = 'https://mediathekviewweb.de/api/query'
|
|
|
|
params['method'] = 'POST'
|
|
|
|
params['headers']['Content-type'] = 'text/plain'
|
2021-12-27 08:26:22 +00:00
|
|
|
params['data'] = dumps(
|
|
|
|
{
|
|
|
|
'queries': [
|
|
|
|
{
|
|
|
|
'fields': [
|
|
|
|
'title',
|
|
|
|
'topic',
|
|
|
|
],
|
|
|
|
'query': query,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'sortBy': 'timestamp',
|
|
|
|
'sortOrder': 'desc',
|
|
|
|
'future': True,
|
|
|
|
'offset': (params['pageno'] - 1) * 10,
|
|
|
|
'size': 10,
|
|
|
|
}
|
|
|
|
)
|
2021-02-09 12:08:01 +00:00
|
|
|
return params
|
|
|
|
|
2021-12-27 08:26:22 +00:00
|
|
|
|
2021-02-09 12:08:01 +00:00
|
|
|
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']))
|
|
|
|
|
2021-12-27 08:26:22 +00:00
|
|
|
results.append(
|
|
|
|
{
|
2022-03-07 18:49:16 +00:00
|
|
|
'url': item['url_video_hd'].replace("http://", "https://"),
|
2021-12-27 08:26:22 +00:00
|
|
|
'title': "%(channel)s: %(title)s (%(hms)s)" % item,
|
|
|
|
'length': item['hms'],
|
|
|
|
'content': "%(description)s" % item,
|
2022-03-07 18:49:16 +00:00
|
|
|
'iframe_src': item['url_video_hd'].replace("http://", "https://"),
|
2022-02-12 17:45:15 +00:00
|
|
|
'template': 'videos.html',
|
2021-12-27 08:26:22 +00:00
|
|
|
}
|
|
|
|
)
|
2021-02-09 12:08:01 +00:00
|
|
|
|
|
|
|
return results
|