utils.py 文件源码

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

项目:netease-dl 作者: ziwenxie 项目源码 文件源码
def select_one_song(songs):
        """Display the songs returned by search api.

        :params songs: API['result']['songs']
        :return: a Song object.
        """

        if len(songs) == 1:
            select_i = 0
        else:
            table = PrettyTable(['Sequence', 'Song Name', 'Artist Name'])
            for i, song in enumerate(songs, 1):
                table.add_row([i, song['name'], song['ar'][0]['name']])
            click.echo(table)

            select_i = click.prompt('Select one song', type=int, default=1)
            while select_i < 1 or select_i > len(songs):
                select_i = click.prompt('Error Select! Select Again', type=int)

        song_id, song_name = songs[select_i-1]['id'], songs[select_i-1]['name']
        song = Song(song_id, song_name)
        return song
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号