From 3a8b67ff82d79f499f78d5cedfadb43a86101983 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Sun, 9 Mar 2025 05:22:16 +0300 Subject: [PATCH] normalize return response for api/history/add --- API.md | 14 ++++++-------- app/library/HttpAPI.py | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/API.md b/API.md index e396eeb1..729dd049 100644 --- a/API.md +++ b/API.md @@ -171,21 +171,19 @@ or an error: **Purpose**: **(Quick Add)** Add a single URL to the download queue via GET. **Query Parameters**: -- `?url=` +- `url=` +- `preset=` **Response**: ```json { - "status": "(ok|error)", -} -``` -or an error: -```json -{ - "error": "text" + "status": true|false, # true if added to the queue. false otherwise. + "message": "..." # the response message. } ``` + - If `url` is missing, returns `400 Bad Request`. +- If `preset` is set and not found, returns `404 Not Found`. --- diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index 10bfa23c..5cf0e176 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -628,7 +628,7 @@ class HttpAPI(Common): return web.json_response(data={"status": False, "message": str(e)}, status=web.HTTPBadRequest.status_code) return web.json_response( - data={"status": True, "message": "URL added", "item": status}, + data={"status": status.get("status") == "ok", "message": status.get("msg", "URL added")}, status=web.HTTPOk.status_code, dumps=self.encoder.encode, )