.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
ccc_media.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""media.ccc.de"""
3
4import datetime
5from urllib.parse import urlencode
6
7from dateutil import parser
8
9about = {
10 'website': 'https://media.ccc.de',
11 'official_api_documentation': 'https://github.com/voc/voctoweb',
12 'use_official_api': True,
13 'require_api_key': False,
14 'results': 'JSON',
15}
16categories = ['videos']
17paging = True
18
19api_url = "https://api.media.ccc.de"
20
21
22def request(query, params):
23 args = {'q': query, 'page': params['pageno']}
24 params['url'] = f"{api_url}/public/events/search?{urlencode(args)}"
25
26 return params
27
28
29def response(resp):
30 results = []
31
32 for item in resp.json()['events']:
33 publishedDate = None
34 if item.get('date'):
35 publishedDate = parser.parse(item['date'])
36
37 iframe_src = None
38 for rec in item['recordings']:
39 if rec['mime_type'].startswith('video'):
40 if not iframe_src:
41 iframe_src = rec['recording_url']
42 elif rec['mime_type'] == 'video/mp4':
43 # prefer mp4 (minimal data rates)
44 iframe_src = rec['recording_url']
45
46 results.append(
47 {
48 'template': 'videos.html',
49 'url': item['frontend_link'],
50 'title': item['title'],
51 'content': item['description'],
52 'thumbnail': item['thumb_url'],
53 'publishedDate': publishedDate,
54 'length': datetime.timedelta(seconds=item['length']),
55 'iframe_src': iframe_src,
56 }
57 )
58
59 return results
request(query, params)
Definition ccc_media.py:22