76def response(resp):
77 """Get response from Bing-Video"""
78 results = []
79
80 dom = html.fromstring(resp.text)
81
82 for result in dom.xpath('//div[@class="dg_u"]//div[contains(@id, "mc_vtvc_video")]'):
83 metadata = json.loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0])
84 info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip()
85 content = '{0} - {1}'.format(metadata['du'], info)
86 thumbnail = result.xpath('.//div[contains(@class, "mc_vtvc_th")]//img/@src')[0]
87
88 results.append(
89 {
90 'url': metadata['murl'],
91 'thumbnail': thumbnail,
92 'title': metadata.get('vt', ''),
93 'content': content,
94 'template': 'videos.html',
95 }
96 )
97
98 return results