music_apis.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号