mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-12 20:15:10 +00:00
feat(serve): relay service prompts from download jobs to the REST client
A job's input_prompt carries a service's request_input() prompt; the client answers it with POST /api/download/jobs/{job_id}/input.
This commit is contained in:
@@ -551,7 +551,8 @@ Show download jobs, with optional filtering and sorting.
|
||||
"segments_done": 120,
|
||||
"segments_total": 300,
|
||||
"speed": "5.2 MB/s",
|
||||
"skipped_subtitles": []
|
||||
"skipped_subtitles": [],
|
||||
"input_prompt": null
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -709,6 +710,36 @@ Move a queued job to the front of the download queue.
|
||||
| `404` | `JOB_NOT_FOUND` | No such job. |
|
||||
| `409` | `CONFLICT` | Job is not queued. |
|
||||
|
||||
### `POST /api/download/jobs/{job_id}/input`
|
||||
|
||||
Answer the prompt that a running job waits on. A service can ask for input during a job, for
|
||||
example an OTP code, a PIN, or a device-code confirmation. The job then shows the prompt in its
|
||||
`input_prompt` field and in its `progress` events. Show the prompt to the user and send the
|
||||
answer here.
|
||||
|
||||
=== "Request"
|
||||
|
||||
```json
|
||||
{ "response": "123456" }
|
||||
```
|
||||
|
||||
=== "Response `200`"
|
||||
|
||||
```json
|
||||
{ "status": "accepted" }
|
||||
```
|
||||
|
||||
| Status | Error code | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `200` | - | Answer sent to the job. The `input_prompt` field goes back to `null`. |
|
||||
| `400` | `INVALID_INPUT` | The body is not JSON, or it has no `response`. |
|
||||
| `404` | `JOB_NOT_FOUND` | No such job. |
|
||||
| `409` | `CONFLICT` | The job does not wait on a prompt. |
|
||||
|
||||
!!! warning
|
||||
The job keeps its download slot while it waits. It fails with `AUTH_FAILED` if nobody
|
||||
answers the prompt within 10 minutes.
|
||||
|
||||
---
|
||||
|
||||
## Server management
|
||||
|
||||
Reference in New Issue
Block a user