rest_api.py 文件源码

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

项目:MusicBot 作者: BjoernPetersen 项目源码 文件源码
def get_available_offline_playlists(user: hug.directives.user, response=None):
    """
    Get all available playlists of the offline API.
    :return: a list of playlists of the form {'playlist_id': <id>, 'playlist_name': <name>}
    """
    if not has_permission(user, ["admin", "mod", "select_playlist"]):
        response.status = falcon.HTTP_FORBIDDEN
        return "Forbidden"
    try:
        api = music_api_names['offline_api']
        playlists = api.get_available_playlists()
        return list(map(lambda p: {'playlist_id': p[0], 'playlist_name': p[1]}, playlists))
    except KeyError:
        response.status = falcon.HTTP_400
        return "Not in offline mode"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号