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"
评论列表
文章目录