normalize return response for api/history/add
This commit is contained in:
parent
68228294b0
commit
3a8b67ff82
2 changed files with 7 additions and 9 deletions
14
API.md
14
API.md
|
|
@ -171,21 +171,19 @@ or an error:
|
||||||
**Purpose**: **(Quick Add)** Add a single URL to the download queue via GET.
|
**Purpose**: **(Quick Add)** Add a single URL to the download queue via GET.
|
||||||
|
|
||||||
**Query Parameters**:
|
**Query Parameters**:
|
||||||
- `?url=<video-url>`
|
- `url=<video-url>`
|
||||||
|
- `preset=<preset-name>`
|
||||||
|
|
||||||
**Response**:
|
**Response**:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"status": "(ok|error)",
|
"status": true|false, # true if added to the queue. false otherwise.
|
||||||
}
|
"message": "..." # the response message.
|
||||||
```
|
|
||||||
or an error:
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"error": "text"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- If `url` is missing, returns `400 Bad Request`.
|
- If `url` is missing, returns `400 Bad Request`.
|
||||||
|
- If `preset` is set and not found, returns `404 Not Found`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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": False, "message": str(e)}, status=web.HTTPBadRequest.status_code)
|
||||||
|
|
||||||
return web.json_response(
|
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,
|
status=web.HTTPOk.status_code,
|
||||||
dumps=self.encoder.encode,
|
dumps=self.encoder.encode,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue