Add interactive release search (M6)
Release listing and grab in the shared arr client, a full-screen release list (sort, hide rejected, rejection reasons, confirmation before grabbing rejected releases; Usenet only), and a season/episode picker for Sonarr. Overlays are now a stack so dialogs can open above the release list. Add a fake Newznab indexer to the dev setup. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package arr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const releasesJSON = `[
|
||||
{"guid":"g1","title":"Movie.2020.1080p.BluRay-GRP","indexer":"NZBgeek","indexerId":3,"protocol":"usenet","size":8589934592,
|
||||
"ageMinutes":4320,"qualityWeight":1801,"customFormatScore":10,"releaseGroup":"GRP","approved":true,"rejected":false,
|
||||
"rejections":[],"quality":{"quality":{"name":"Bluray-1080p"}},"languages":[{"name":"English"},{"name":"German"}]},
|
||||
{"guid":"g2","title":"Movie.2020.720p-X","indexer":"Other","indexerId":4,"protocol":"torrent","approved":false,"rejected":true,
|
||||
"rejections":["Quality Bluray-720p is not wanted in profile","Release is older than 30 days"],"quality":{"quality":{"name":"Bluray-720p"}}}
|
||||
]`
|
||||
|
||||
func TestReleases(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/v3/release" || r.URL.Query().Get("movieId") != "12" {
|
||||
t.Errorf("unexpected request %s", r.URL)
|
||||
}
|
||||
w.Write([]byte(releasesJSON))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
rels, err := NewClient(srv.URL, "k").Releases(context.Background(), url.Values{"movieId": {"12"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(rels) != 2 {
|
||||
t.Fatalf("got %d releases", len(rels))
|
||||
}
|
||||
a, b := rels[0], rels[1]
|
||||
if a.QualityName() != "Bluray-1080p" || a.Size != 8<<30 || !a.Approved || a.IndexerID != 3 || a.LanguageNames() != "English, German" {
|
||||
t.Errorf("release a = %+v", a)
|
||||
}
|
||||
if !b.Rejected || len(b.Rejections) != 2 || b.Protocol != "torrent" {
|
||||
t.Errorf("release b = %+v", b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGrab(t *testing.T) {
|
||||
var got map[string]any
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost || r.URL.Path != "/api/v3/release" {
|
||||
t.Errorf("unexpected request %s %s", r.Method, r.URL)
|
||||
}
|
||||
json.NewDecoder(r.Body).Decode(&got)
|
||||
w.Write([]byte(`{}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient(srv.URL, "k")
|
||||
if err := c.Grab(context.Background(), Release{GUID: "g1", IndexerID: 3}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got["guid"] != "g1" || got["indexerId"] != float64(3) {
|
||||
t.Errorf("body = %v", got)
|
||||
}
|
||||
if err := c.Grab(context.Background(), Release{}); err == nil {
|
||||
t.Error("expected error for release without guid")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user