Shared arr HTTP client with API error handling, plus Radarr lookup, add movie, search and quality profile / root folder / status endpoints. Tested against httptest fixtures. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package arr
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// SystemStatus is the subset of /system/status we use.
|
|
type SystemStatus struct {
|
|
AppName string `json:"appName"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
// QualityProfile is a Radarr/Sonarr quality profile.
|
|
type QualityProfile struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// RootFolder is a configured library root.
|
|
type RootFolder struct {
|
|
ID int `json:"id"`
|
|
Path string `json:"path"`
|
|
FreeSpace int64 `json:"freeSpace"`
|
|
Accessible bool `json:"accessible"`
|
|
}
|
|
|
|
// Image is a poster/fanart reference.
|
|
type Image struct {
|
|
CoverType string `json:"coverType"`
|
|
URL string `json:"url,omitempty"`
|
|
RemoteURL string `json:"remoteUrl,omitempty"`
|
|
}
|
|
|
|
// SystemStatus fetches /system/status.
|
|
func (c *Client) SystemStatus(ctx context.Context) (SystemStatus, error) {
|
|
var s SystemStatus
|
|
err := c.Do(ctx, http.MethodGet, "system/status", nil, nil, &s)
|
|
return s, err
|
|
}
|
|
|
|
// QualityProfiles lists quality profiles.
|
|
func (c *Client) QualityProfiles(ctx context.Context) ([]QualityProfile, error) {
|
|
var p []QualityProfile
|
|
err := c.Do(ctx, http.MethodGet, "qualityprofile", nil, nil, &p)
|
|
return p, err
|
|
}
|
|
|
|
// RootFolders lists root folders.
|
|
func (c *Client) RootFolders(ctx context.Context) ([]RootFolder, error) {
|
|
var f []RootFolder
|
|
err := c.Do(ctx, http.MethodGet, "rootfolder", nil, nil, &f)
|
|
return f, err
|
|
}
|