def _song_from_info(self, info) -> Song:
"""
Create a song object from the json dict returned by the HTTP API.
:param info: the json dict
:return: a Song object, or None
"""
song_id = str(info.id)
songs = self._songs
if song_id in songs:
return songs[song_id]
if not info.streamable and not info.downloadable:
return None
artist = info.user['username']
title = info.title
url = info.artwork_url
duration_millis = info.duration
duration = datetime.fromtimestamp(duration_millis / 1000).strftime("%M:%S")
song = Song(song_id, self, title, artist, url, " - ".join([artist, title]), duration=duration)
songs[song_id] = song
return song
评论列表
文章目录