0.2.63 update

This commit is contained in:
ponzischeme89
2026-08-14 11:47:32 +12:00
parent 9a8ecbdceb
commit 06b6490ac9
41 changed files with 921 additions and 179 deletions
+34 -17
View File
@@ -58,7 +58,31 @@ type RootFolder struct {
}
type QualityProfile struct {
ID int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
}
// RequestOptions are Memby's deliberate movie-request policy. Radarr defaults are never
// allowed to choose a profile or initiate a search on Memby's behalf.
type RequestOptions struct {
QualityProfileID int
SearchImmediately bool
}
func (c *Client) RootFolders(ctx context.Context) ([]RootFolder, error) {
var roots []RootFolder
if err := c.get(ctx, "/api/v3/rootfolder", &roots); err != nil {
return nil, err
}
return roots, nil
}
func (c *Client) QualityProfiles(ctx context.Context) ([]QualityProfile, error) {
var profiles []QualityProfile
if err := c.get(ctx, "/api/v3/qualityprofile", &profiles); err != nil {
return nil, err
}
return profiles, nil
}
type APIError struct {
@@ -116,29 +140,22 @@ func (c *Client) Lookup(ctx context.Context, term string) ([]Movie, error) {
return movies, nil
}
// AddRequested adds a title, monitors it and asks Radarr to search for it immediately.
// A request that merely creates an unmonitored catalogue row never reaches a downloader,
// which is indistinguishable from a broken button to the viewer who made it.
func (c *Client) AddRequested(ctx context.Context, movie Movie) (Movie, error) {
var roots []RootFolder
if err := c.get(ctx, "/api/v3/rootfolder", &roots); err != nil {
return Movie{}, err
// AddRequested adds a monitored movie using the supplied request policy.
func (c *Client) AddRequested(ctx context.Context, movie Movie, rootFolder string, options RequestOptions) (Movie, error) {
if strings.TrimSpace(rootFolder) == "" {
return Movie{}, fmt.Errorf("radarr: request root folder is required")
}
var profiles []QualityProfile
if err := c.get(ctx, "/api/v3/qualityprofile", &profiles); err != nil {
return Movie{}, err
}
if len(roots) == 0 || len(profiles) == 0 {
return Movie{}, fmt.Errorf("radarr: no root folder or quality profile configured")
if options.QualityProfileID <= 0 {
return Movie{}, fmt.Errorf("radarr: request quality profile is required")
}
movie.ID = 0
movie.RootFolderPath = roots[0].Path
movie.QualityProfileID = profiles[0].ID
movie.RootFolderPath = rootFolder
movie.QualityProfileID = options.QualityProfileID
movie.Monitored = true
body := struct {
Movie
AddOptions map[string]bool `json:"addOptions"`
}{Movie: movie, AddOptions: map[string]bool{"searchForMovie": true}}
}{Movie: movie, AddOptions: map[string]bool{"searchForMovie": options.SearchImmediately}}
var added Movie
if err := c.post(ctx, "/api/v3/movie", body, &added); err != nil {
return Movie{}, err