def _song_from_info(self, info):
if "id" in info:
song_id = info['id']
else:
song_id = info['storeId']
songs = self._songs
if song_id in songs:
return songs[song_id]
artist = info['artist']
title = info['title']
duration_millis = int(info['durationMillis'])
duration = datetime.fromtimestamp(duration_millis / 1000).strftime("%M:%S")
url = None
if "albumArtRef" in info:
ref = info["albumArtRef"]
if ref:
ref = ref[0]
if "url" in ref:
url = ref["url"]
song = Song(song_id, self, title, artist, url, " - ".join([artist, title]), duration)
songs[song_id] = song
return song
评论列表
文章目录