Implement api.playlist_remove_or_clear

It handles both mpv_control.playlist_remove and mpv_control.playlist_clear
This commit is contained in:
Peder Bergebakken Sundt 2018-03-04 14:35:12 +01:00
parent 6388a8bfc3
commit 0b64705fdb

View File

@ -138,7 +138,7 @@ async def playlist_get(request, mpv_control):
v["index"] = i v["index"] = i
if "current" in v and v["current"] == True: if "current" in v and v["current"] == True:
v["playing"] = await mpv_control.pause_get() == False v["playing"] = await mpv_control.pause_get() == False
del i, v if value: del i, v
return locals() return locals()
@bp.post("/playlist/next") @bp.post("/playlist/next")
@ -155,16 +155,17 @@ async def playlist_previous(request, mpv_control):
success = await mpv_control.playlist_prev() success = await mpv_control.playlist_prev()
return locals() return locals()
#@bp.get("/something") @bp.delete("/playlist")
@doc.summary("Clears single item or whole playlist")
@doc.consumes({"index": doc.Integer("Index to item in playlist to remove. If unset, the whole playlist is cleared")})
@response_json @response_json
async def noe(request, mpv_control): async def playlist_remove_or_clear(request, mpv_control):
value = await mpv_control.playlist_clear() if "index" in request.args:
return locals() success = await mpv_control.playlist_remove(int(request.args["index"][0]))
action = f"remove #{request.args['index'][0]}"
#@bp.get("/something") else:
@response_json success = await mpv_control.playlist_clear()
async def noe(request, mpv_control): action = "clear all"
value = await mpv_control.playlist_remove(index=None)
return locals() return locals()
#@bp.get("/something") #@bp.get("/something")