Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ linters:
disable:
- dupl
- exhaustruct
- exhaustruct_v5
- musttag
- nlreturn
- tagliatelle
Expand Down Expand Up @@ -40,6 +41,7 @@ linters:
- funlen
- gochecknoglobals
- lll
- goconst
- maintidx
path: (.+)_test\.go
- linters:
Expand Down
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ go 1.25.7

toolchain go1.27.0

require golang.org/x/net v0.49.0 // publicsuffix, cookiejar.
require golang.org/x/net v0.58.0 // publicsuffix, cookiejar.

// All of this is for the tests.
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.12.1 // assert!
gopkg.in/yaml.v3 v3.0.1 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
)

require go.yaml.in/yaml/v3 v3.0.5 // indirect
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
6 changes: 6 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/tls"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -65,6 +66,11 @@ func Itoa(v int64) string {
return Str(v)
}

// ForceSave returns the query values used by Starr apps to force-save a resource.
func ForceSave(force bool) url.Values {
return url.Values{"forceSave": []string{Str(force)}}
}

// Str converts numbers and booleans to a string.
func Str[I int | int64 | float64 | bool](val I) string {
const (
Expand Down
5 changes: 2 additions & 3 deletions lidarr/downloadclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -99,7 +98,7 @@ func (l *Lidarr) AddDownloadClientContext(ctx context.Context,
return nil, fmt.Errorf("json.Marshal(%s): %w", bpDownloadClient, err)
}

req := starr.Request{URI: bpDownloadClient, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpDownloadClient, Body: &body, Query: starr.ForceSave(true)}
if err := l.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -149,7 +148,7 @@ func (l *Lidarr) UpdateDownloadClientContext(ctx context.Context,
req := starr.Request{
URI: path.Join(bpDownloadClient, starr.Str(client.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := l.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions lidarr/importlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -110,7 +109,7 @@ func (l *Lidarr) AddImportListContext(ctx context.Context, importList *ImportLis
return nil, fmt.Errorf("json.Marshal(%s): %w", bpImportList, err)
}

req := starr.Request{URI: bpImportList, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpImportList, Body: &body, Query: starr.ForceSave(true)}
if err := l.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -161,7 +160,7 @@ func (l *Lidarr) UpdateImportListContext(
req := starr.Request{
URI: path.Join(bpImportList, starr.Str(importList.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := l.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions lidarr/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -120,7 +119,7 @@ func (l *Lidarr) AddIndexerContext(ctx context.Context, indexer *IndexerInput) (
return nil, fmt.Errorf("json.Marshal(%s): %w", bpIndexer, err)
}

req := starr.Request{URI: bpIndexer, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpIndexer, Body: &body, Query: starr.ForceSave(true)}
if err := l.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand All @@ -145,7 +144,7 @@ func (l *Lidarr) UpdateIndexerContext(ctx context.Context, indexer *IndexerInput
req := starr.Request{
URI: path.Join(bpIndexer, starr.Str(indexer.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := l.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
4 changes: 2 additions & 2 deletions prowlarr/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p *Prowlarr) AddApplicationContext(
req := starr.Request{
URI: bpApplication,
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(forceSave)}},
Query: starr.ForceSave(forceSave),
}
if err := p.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
Expand Down Expand Up @@ -123,7 +123,7 @@ func (p *Prowlarr) UpdateApplicationContext(
req := starr.Request{
URI: path.Join(bpApplication, starr.Str(app.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(forceSave)}},
Query: starr.ForceSave(forceSave),
}
if err := p.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions prowlarr/downloadclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -95,7 +94,7 @@ func (p *Prowlarr) AddDownloadClientContext(ctx context.Context,
return nil, fmt.Errorf("json.Marshal(%s): %w", bpDownloadClient, err)
}

req := starr.Request{URI: bpDownloadClient, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpDownloadClient, Body: &body, Query: starr.ForceSave(true)}
if err := p.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -145,7 +144,7 @@ func (p *Prowlarr) UpdateDownloadClientContext(ctx context.Context,
req := starr.Request{
URI: path.Join(bpDownloadClient, starr.Str(client.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := p.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions prowlarr/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"
"time"

Expand Down Expand Up @@ -160,7 +159,7 @@ func (p *Prowlarr) AddIndexerContext(ctx context.Context, indexer *IndexerInput)
return nil, fmt.Errorf("json.Marshal(%s): %w", bpIndexer, err)
}

req := starr.Request{URI: bpIndexer, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpIndexer, Body: &body, Query: starr.ForceSave(true)}
if err := p.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -189,7 +188,7 @@ func (p *Prowlarr) UpdateIndexerContext(
req := starr.Request{
URI: path.Join(bpIndexer, starr.Str(indexer.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := p.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
4 changes: 2 additions & 2 deletions prowlarr/indexerproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (p *Prowlarr) AddIndexerProxyContext(
req := starr.Request{
URI: bpIndexerProxy,
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(forceSave)}},
Query: starr.ForceSave(forceSave),
}
if err := p.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
Expand Down Expand Up @@ -134,7 +134,7 @@ func (p *Prowlarr) UpdateIndexerProxyContext(
req := starr.Request{
URI: path.Join(bpIndexerProxy, starr.Str(proxy.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(forceSave)}},
Query: starr.ForceSave(forceSave),
}
if err := p.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions radarr/downloadclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -99,7 +98,7 @@ func (r *Radarr) AddDownloadClientContext(ctx context.Context,
return nil, fmt.Errorf("json.Marshal(%s): %w", bpDownloadClient, err)
}

req := starr.Request{URI: bpDownloadClient, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpDownloadClient, Body: &body, Query: starr.ForceSave(true)}
if err := r.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -149,7 +148,7 @@ func (r *Radarr) UpdateDownloadClientContext(ctx context.Context,
req := starr.Request{
URI: path.Join(bpDownloadClient, starr.Str(client.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := r.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions radarr/importlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"
"strings"

Expand Down Expand Up @@ -90,7 +89,7 @@ func (r *Radarr) AddImportListContext(ctx context.Context, list *ImportListInput
return nil, fmt.Errorf("json.Marshal(%s): %w", bpImportList, err)
}

req := starr.Request{URI: bpImportList, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpImportList, Body: &body, Query: starr.ForceSave(true)}
if err := r.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -164,7 +163,7 @@ func (r *Radarr) UpdateImportListContext(
req := starr.Request{
URI: path.Join(bpImportList, starr.Str(importList.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := r.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions radarr/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -122,7 +121,7 @@ func (r *Radarr) AddIndexerContext(ctx context.Context, indexer *IndexerInput) (
return nil, fmt.Errorf("json.Marshal(%s): %w", bpIndexer, err)
}

req := starr.Request{URI: bpIndexer, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpIndexer, Body: &body, Query: starr.ForceSave(true)}
if err := r.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand All @@ -147,7 +146,7 @@ func (r *Radarr) UpdateIndexerContext(ctx context.Context, indexer *IndexerInput
req := starr.Request{
URI: path.Join(bpIndexer, starr.Str(indexer.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := r.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions readarr/downloadclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -96,7 +95,7 @@ func (r *Readarr) AddDownloadClientContext(ctx context.Context,
return nil, fmt.Errorf("json.Marshal(%s): %w", bpDownloadClient, err)
}

req := starr.Request{URI: bpDownloadClient, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpDownloadClient, Body: &body, Query: starr.ForceSave(true)}
if err := r.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -146,7 +145,7 @@ func (r *Readarr) UpdateDownloadClientContext(ctx context.Context,
req := starr.Request{
URI: path.Join(bpDownloadClient, starr.Str(client.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := r.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions readarr/importlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -106,7 +105,7 @@ func (r *Readarr) AddImportListContext(ctx context.Context, importList *ImportLi
return nil, fmt.Errorf("json.Marshal(%s): %w", bpImportList, err)
}

req := starr.Request{URI: bpImportList, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpImportList, Body: &body, Query: starr.ForceSave(true)}
if err := r.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand Down Expand Up @@ -157,7 +156,7 @@ func (r *Readarr) UpdateImportListContext(
req := starr.Request{
URI: path.Join(bpImportList, starr.Str(importList.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := r.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
5 changes: 2 additions & 3 deletions readarr/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/url"
"path"

"golift.io/starr"
Expand Down Expand Up @@ -120,7 +119,7 @@ func (r *Readarr) AddIndexerContext(ctx context.Context, indexer *IndexerInput)
return nil, fmt.Errorf("json.Marshal(%s): %w", bpIndexer, err)
}

req := starr.Request{URI: bpIndexer, Body: &body, Query: url.Values{"forceSave": []string{"true"}}}
req := starr.Request{URI: bpIndexer, Body: &body, Query: starr.ForceSave(true)}
if err := r.PostInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Post(%s): %w", &req, err)
}
Expand All @@ -145,7 +144,7 @@ func (r *Readarr) UpdateIndexerContext(ctx context.Context, indexer *IndexerInpu
req := starr.Request{
URI: path.Join(bpIndexer, starr.Str(indexer.ID)),
Body: &body,
Query: url.Values{"forceSave": []string{starr.Str(force)}},
Query: starr.ForceSave(force),
}
if err := r.PutInto(ctx, req, &output); err != nil {
return nil, fmt.Errorf("api.Put(%s): %w", &req, err)
Expand Down
Loading
Loading