diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index 8ce7b562..10bfa23c 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -614,19 +614,24 @@ class HttpAPI(Common): preset = request.query.get("preset") if preset: - exists = Presets.get_instance().get(preset) + exists = Presets.get_instance().get(name=preset) if not exists: return web.json_response( - data={"error": f"Preset '{preset}' does not exist."}, status=web.HTTPBadRequest.status_code + data={"status": False, "message": f"Preset '{preset}' does not exist."}, + status=web.HTTPBadRequest.status_code, ) data["preset"] = preset try: 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) + return web.json_response(data={"status": False, "message": str(e)}, status=web.HTTPBadRequest.status_code) - return web.json_response(data=status, status=web.HTTPOk.status_code, dumps=self.encoder.encode) + return web.json_response( + data={"status": True, "message": "URL added", "item": status}, + status=web.HTTPOk.status_code, + dumps=self.encoder.encode, + ) @route("POST", "api/history") async def history_item_add(self, request: Request) -> Response: diff --git a/app/library/Presets.py b/app/library/Presets.py index e2f8a271..d9aa29e2 100644 --- a/app/library/Presets.py +++ b/app/library/Presets.py @@ -251,7 +251,7 @@ class Presets(metaclass=Singleton): try: with open(self._file, "w") as f: - json.dump(obj=[preset.serialize() for preset in presets], fp=f, indent=4) + json.dump(obj=[preset.serialize() for preset in presets if preset.default is False], fp=f, indent=4) LOG.info(f"Presets saved to '{self._file}'.") except Exception as e: