0.2.55 - Remote config/Request fixes
This commit is contained in:
@@ -168,8 +168,9 @@ func (c *Client) Lookup(ctx context.Context, term string) ([]Series, error) {
|
||||
return series, nil
|
||||
}
|
||||
|
||||
// AddUnmonitored adds a series without monitoring it or starting an episode search.
|
||||
func (c *Client) AddUnmonitored(ctx context.Context, series Series) (Series, error) {
|
||||
// AddRequested adds a series, monitors its seasons and asks Sonarr to search for missing
|
||||
// episodes immediately. An unmonitored catalogue row does not fulfil a media request.
|
||||
func (c *Client) AddRequested(ctx context.Context, series Series) (Series, error) {
|
||||
var roots []RootFolder
|
||||
if err := c.get(ctx, "/api/v3/rootfolder", &roots); err != nil {
|
||||
return Series{}, err
|
||||
@@ -184,15 +185,15 @@ func (c *Client) AddUnmonitored(ctx context.Context, series Series) (Series, err
|
||||
series.ID = 0
|
||||
series.RootFolderPath = roots[0].Path
|
||||
series.QualityProfileID = profiles[0].ID
|
||||
series.Monitored = false
|
||||
series.Monitored = true
|
||||
series.SeasonFolder = true
|
||||
for i := range series.Seasons {
|
||||
series.Seasons[i].Monitored = false
|
||||
series.Seasons[i].Monitored = true
|
||||
}
|
||||
body := struct {
|
||||
Series
|
||||
AddOptions map[string]bool `json:"addOptions"`
|
||||
}{Series: series, AddOptions: map[string]bool{"searchForMissingEpisodes": false}}
|
||||
}{Series: series, AddOptions: map[string]bool{"searchForMissingEpisodes": true}}
|
||||
var added Series
|
||||
if err := c.post(ctx, "/api/v3/series", body, &added); err != nil {
|
||||
return Series{}, err
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestCalendarUsesV3APIAndKeepsKeyInHeader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddUnmonitoredUsesDefaultsWithoutStartingSearch(t *testing.T) {
|
||||
func TestAddRequestedUsesDefaultsAndStartsSearch(t *testing.T) {
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/api/v3/rootfolder":
|
||||
@@ -58,17 +58,17 @@ func TestAddUnmonitoredUsesDefaultsWithoutStartingSearch(t *testing.T) {
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["monitored"] != false || body["seasonFolder"] != true ||
|
||||
if body["monitored"] != true || body["seasonFolder"] != true ||
|
||||
body["rootFolderPath"] != "/tv" || body["qualityProfileId"] != float64(3) {
|
||||
t.Errorf("unexpected add body: %#v", body)
|
||||
}
|
||||
seasons := body["seasons"].([]any)
|
||||
if seasons[0].(map[string]any)["monitored"] != false {
|
||||
t.Errorf("season remained monitored: %#v", body)
|
||||
if seasons[0].(map[string]any)["monitored"] != true {
|
||||
t.Errorf("season was not monitored: %#v", body)
|
||||
}
|
||||
options := body["addOptions"].(map[string]any)
|
||||
if options["searchForMissingEpisodes"] != false {
|
||||
t.Errorf("episode search was enabled: %#v", body)
|
||||
if options["searchForMissingEpisodes"] != true {
|
||||
t.Errorf("episode search was not enabled: %#v", body)
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"id":8,"tvdbId":44,"title":"Severance"}`))
|
||||
default:
|
||||
@@ -77,10 +77,10 @@ func TestAddUnmonitoredUsesDefaultsWithoutStartingSearch(t *testing.T) {
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
added, err := New(upstream.URL, "secret", time.Second).AddUnmonitored(
|
||||
added, err := New(upstream.URL, "secret", time.Second).AddRequested(
|
||||
context.Background(), Series{
|
||||
TVDBID: 44, Title: "Severance", Monitored: true,
|
||||
Seasons: []Season{{SeasonNumber: 1, Monitored: true}},
|
||||
TVDBID: 44, Title: "Severance",
|
||||
Seasons: []Season{{SeasonNumber: 1}},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user