normalize return response for api/history/add

This commit is contained in:
ArabCoders 2025-03-09 05:22:16 +03:00
parent 68228294b0
commit 3a8b67ff82
2 changed files with 7 additions and 9 deletions

14
API.md
View file

@ -171,21 +171,19 @@ or an error:
**Purpose**: **(Quick Add)** Add a single URL to the download queue via GET.
**Query Parameters**:
- `?url=<video-url>`
- `url=<video-url>`
- `preset=<preset-name>`
**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`.
---

View file

@ -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,
)