37def response(resp):
38 results = []
39
40 json_resp = resp.json()
41
42 for result in json_resp['teaser']:
43 thumbnail = None
44 if result['teaser']['image']:
45 thumbnail = base_url + result['teaser']['image']['sources'][-1]['url']
46
47 metadata = result['extension']['overline']
48 authors = ', '.join(author['name'] for author in result['extension'].get('authors', []))
49 if authors:
50 metadata += f" | {authors}"
51
52 publishedDate = None
53 if result['extension'].get('publishingDate'):
54 publishedDate = datetime.utcfromtimestamp(result['extension']['publishingDate'])
55
56 results.append(
57 {
58 'url': base_url + result['teaser']['link']['url'],
59 'title': result['teaser']['title'],
60 'content': result['teaser']['text'],
61 'thumbnail': thumbnail,
62 'publishedDate': publishedDate,
63 'metadata': metadata,
64 }
65 )
66
67 return results