This commit is contained in:
ponzischeme89
2026-08-19 14:25:44 +12:00
parent 2b43b9ef12
commit 590e069366
83 changed files with 8948 additions and 1266 deletions
+43
View File
@@ -307,3 +307,46 @@ func (c *Client) do(req *http.Request, out any) error {
}
return nil
}
// QueueItem is one episode the download client is working on. See radarr.QueueItem for why
// three status words are carried rather than one; Sonarr describes a download in the same
// vocabulary.
//
// SeriesID is what the request page joins on: a viewer asks for a show, and what comes back
// is some number of episodes of it.
type QueueItem struct {
ID int `json:"id"`
SeriesID int `json:"seriesId"`
EpisodeID int `json:"episodeId"`
Size float64 `json:"size"`
Sizeleft float64 `json:"sizeleft"`
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; see radarr's own note.
const queuePageSize = 200
type queuePage struct {
Records []QueueItem `json:"records"`
}
// Queue returns what Sonarr is currently working on, excluding downloads it cannot match to
// a series it tracks.
func (c *Client) Queue(ctx context.Context) ([]QueueItem, error) {
req, err := c.request(ctx, "/api/v3/queue", url.Values{
"pageSize": {strconv.Itoa(queuePageSize)},
"includeUnknownSeriesItems": {"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
}