40def parse_lyric(hit):
41 content = ''
42 highlights = hit['highlights']
43 if highlights:
44 content = hit['highlights'][0]['value']
45 else:
46 content = hit['result'].get('title_with_featured', '')
47
48 timestamp = hit['result']['lyrics_updated_at']
49 result = {
50 'url': hit['result']['url'],
51 'title': hit['result']['full_title'],
52 'content': content,
53 'thumbnail': hit['result']['song_art_image_thumbnail_url'],
54 }
55 if timestamp:
56 result.update({'publishedDate': datetime.fromtimestamp(timestamp)})
57 api_path = hit['result'].get('api_path')
58 if api_path:
59
60
61
62 result['iframe_src'] = music_player.format(api_path=api_path)
63 return result
64
65