music_apis.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:MusicBot 作者: BjoernPetersen 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号