rest_api.py 文件源码

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

项目:MusicBot 作者: BjoernPetersen 项目源码 文件源码
def get_active_playlist(user: hug.directives.user, response=None):
    """
    Get the active playlist of the offline API.
    :return: the active playlist 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']
        playlist_tuple = api.get_active_playlist()
        if not playlist_tuple:
            return None
        return {'playlist_id': playlist_tuple[0], 'playlist_name': playlist_tuple[1]}
    except KeyError:
        response.status = falcon.HTTP_400
        return "Not in offline mode"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号