0.2.78
This commit is contained in:
@@ -285,3 +285,59 @@ func (c *Client) Movies(ctx context.Context) ([]Movie, error) {
|
||||
}
|
||||
return movies, nil
|
||||
}
|
||||
|
||||
// QueueItem is one thing the download client is working on, in the narrow shape the
|
||||
// request page needs: which film, how far through, and how it is going.
|
||||
//
|
||||
// Radarr describes a download in three overlapping words rather than one, and all three
|
||||
// are needed. Status is the *download client's* view (queued, downloading, paused,
|
||||
// completed, failed, warning, delay). TrackedDownloadState is Radarr's own view of what
|
||||
// happens after the bytes land (downloading, importPending, importing, imported,
|
||||
// failedPending, failed) — which is the only thing that separates "still coming down the
|
||||
// wire" from "almost on the shelf". TrackedDownloadStatus is the verdict (ok, warning,
|
||||
// error), and is what says an otherwise healthy-looking row has actually gone wrong.
|
||||
type QueueItem struct {
|
||||
ID int `json:"id"`
|
||||
MovieID int `json:"movieId"`
|
||||
// Size and Sizeleft are bytes, as floats — Radarr sends them that way, and a film is
|
||||
// comfortably past what a 32-bit int holds.
|
||||
Size float64 `json:"size"`
|
||||
Sizeleft float64 `json:"sizeleft"`
|
||||
// Timeleft is the download client's own estimate, formatted "00:14:32" or
|
||||
// "1.02:03:04". It is absent for a queued or stalled item, which is exactly the case
|
||||
// where Memby must not invent one.
|
||||
Timeleft string `json:"timeleft"`
|
||||
Status string `json:"status"`
|
||||
TrackedDownloadState string `json:"trackedDownloadState"`
|
||||
TrackedDownloadStatus string `json:"trackedDownloadStatus"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
}
|
||||
|
||||
// queuePageSize is what one read asks for. The queue is what the household is downloading
|
||||
// right now, so it is small by nature; the cap exists so a download client that has wedged
|
||||
// with a thousand rows cannot turn a request-page refresh into a large response.
|
||||
const queuePageSize = 200
|
||||
|
||||
type queuePage struct {
|
||||
Records []QueueItem `json:"records"`
|
||||
}
|
||||
|
||||
// Queue returns what Radarr is currently working on.
|
||||
//
|
||||
// Unknown items are excluded: those are downloads in the client that Radarr cannot match
|
||||
// to a film it tracks, so they can never be the answer to "what is happening to the thing
|
||||
// I asked for" and would only be rows nothing could use.
|
||||
func (c *Client) Queue(ctx context.Context) ([]QueueItem, error) {
|
||||
req, err := c.request(ctx, "/api/v3/queue", url.Values{
|
||||
"pageSize": {strconv.Itoa(queuePageSize)},
|
||||
"includeUnknownMovieItems": {"false"},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var page queuePage
|
||||
if err := c.do(req, &page); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return page.Records, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user