From f89e72666b7964c22073ecc5a2f57b2ad9089fcb Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Fri, 7 Mar 2025 20:16:19 +0300 Subject: [PATCH] make to possible to specify the preset when adding via /api/history/add --- app/library/HttpAPI.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index fb77f979..67535b8c 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -608,8 +608,21 @@ class HttpAPI(Common): if not url: return web.json_response(data={"error": "url param is required."}, status=web.HTTPBadRequest.status_code) + data = { + "url": url, + } + + preset = request.query.get("preset") + if preset: + exists = Presets.get_instance().get(preset) + if not exists: + return web.json_response( + data={"error": f"Preset '{preset}' does not exist."}, status=web.HTTPBadRequest.status_code + ) + data["preset"] = preset + try: - status = await self.add(**self.format_item({"url": url})) + status = await self.add(**self.format_item(data)) except ValueError as e: return web.json_response(data={"error": str(e)}, status=web.HTTPBadRequest.status_code)