how to delete a file using the API?
Hi,
how can i delete a file using the API?
Something along the lines of: curl -X POST "https://metube.local.example.com/delete?file=/downloads/audio/myaudio.ogg"?
(this didn't work)
This doesn't work either:
curl -X POST "https://metube.local.example.com/delete"
-H "Content-Type: application/json"
-d '{
"ids": ["/downloads/audio/myaudio.ogg"],
"where": "done"
}'
At least I get a 200 response code with {"status": "ok"}, but the file is not deleted.
The idea above is based on this function in this delete function in /app/main.py:
@routes.post(config.URL_PREFIX + 'delete') async def delete(request): post = await request.json() ids = post.get('ids') where = post.get('where') if not ids or where not in ['queue', 'done']: raise web.HTTPBadRequest() status = await (dqueue.cancel(ids) if where == 'queue' else dqueue.clear(ids)) return web.Response(text=serializer.encode(status))
Try to get the history from: curl -s -X GET 'https://your.local.metube/history' --header 'Content-Type: application/json'
This will return a JSON similar to:
{ "done": [ { "id": "partOfTheUrl", "title": "....", "url": "https://www.theurl.com/?p=partOfTheUrl", "quality": "best", "format": "mp3", "folder": null, "custom_name_prefix": "", "msg": null, "percent": 100.0, "speed": null, "eta": null, "status": "finished", "size": 5375677, "timestamp": 1746182276347947839, "error": null, "filename": "...." } ], "queue": [], "pending": [] }
and in my case for the delete call, for the property ids: I sent an array with the value of the urls from the above JSON
Ex. curl -s -X POST 'https://your.local.metube/delete' --header 'Content-Type: application/json' --data "{"where":"done","ids": [ "url" ]}"