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