33def response(resp):
34 results = []
35
36 json_results = loads(resp.text)['data']
37
38 for result in json_results['posts']:
39 result_type = result['type']
40
41
42 if result['images']['image700']['height'] > 400:
43 thumbnail = result['images']['imageFbThumbnail']['url']
44 else:
45 thumbnail = result['images']['image700']['url']
46
47 if result_type == 'Photo':
48 results.append(
49 {
50 'template': 'images.html',
51 'url': result['url'],
52 'title': result['title'],
53 'content': result['description'],
54 'publishedDate': datetime.utcfromtimestamp(result['creationTs']),
55 'img_src': result['images']['image700']['url'],
56 'thumbnail_src': thumbnail,
57 }
58 )
59 elif result_type == 'Animated':
60 results.append(
61 {
62 'template': 'videos.html',
63 'url': result['url'],
64 'title': result['title'],
65 'content': result['description'],
66 'publishedDate': datetime.utcfromtimestamp(result['creationTs']),
67 'thumbnail': thumbnail,
68 'iframe_src': result['images'].get('image460sv', {}).get('url'),
69 }
70 )
71
72 if 'tags' in json_results:
73 for suggestion in json_results['tags']:
74 results.append({'suggestion': suggestion['key']})
75
76 return results