diff --git a/lidarr/lidarr.go b/lidarr/lidarr.go index 78e098d..3ecf476 100644 --- a/lidarr/lidarr.go +++ b/lidarr/lidarr.go @@ -57,7 +57,7 @@ func (l *Lidarr) UpdateQualityProfile(profile *QualityProfile) error { return fmt.Errorf("json.Marshal(profile): %w", err) } - _, err = l.Put("v1/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Bits10), nil, put) + _, err = l.Put("v1/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Base10), nil, put) if err != nil { return fmt.Errorf("api.Put(qualityProfile): %w", err) } @@ -187,7 +187,7 @@ func (l *Lidarr) GetArtist(mbID string) ([]*Artist, error) { func (l *Lidarr) GetArtistByID(artistID int64) (*Artist, error) { var artist Artist - err := l.GetInto("v1/artist/"+strconv.FormatInt(artistID, starr.Bits10), nil, &artist) + err := l.GetInto("v1/artist/"+strconv.FormatInt(artistID, starr.Base10), nil, &artist) if err != nil { return &artist, fmt.Errorf("api.Get(artist): %w", err) } @@ -227,7 +227,7 @@ func (l *Lidarr) UpdateArtist(artist *Artist) (*Artist, error) { var output Artist - err = l.PutInto("v1/artist/"+strconv.FormatInt(artist.ID, starr.Bits10), params, body, &output) + err = l.PutInto("v1/artist/"+strconv.FormatInt(artist.ID, starr.Base10), params, body, &output) if err != nil { return nil, fmt.Errorf("api.Put(artist): %w", err) } @@ -258,7 +258,7 @@ func (l *Lidarr) GetAlbum(mbID string) ([]*Album, error) { func (l *Lidarr) GetAlbumByID(albumID int64) (*Album, error) { var album Album - err := l.GetInto("v1/album/"+strconv.FormatInt(albumID, starr.Bits10), nil, &album) + err := l.GetInto("v1/album/"+strconv.FormatInt(albumID, starr.Base10), nil, &album) if err != nil { return nil, fmt.Errorf("api.Get(album): %w", err) } @@ -278,7 +278,7 @@ func (l *Lidarr) UpdateAlbum(albumID int64, album *Album) (*Album, error) { var output Album - err = l.PutInto("v1/album/"+strconv.FormatInt(albumID, starr.Bits10), params, put, &output) + err = l.PutInto("v1/album/"+strconv.FormatInt(albumID, starr.Base10), params, put, &output) if err != nil { return nil, fmt.Errorf("api.Put(album): %w", err) } diff --git a/radarr/radarr.go b/radarr/radarr.go index c69f4de..f2e3a8b 100644 --- a/radarr/radarr.go +++ b/radarr/radarr.go @@ -122,7 +122,7 @@ func (r *Radarr) GetQueue(maxRecords, page int) (*Queue, error) { func (r *Radarr) GetMovie(tmdbID int64) ([]*Movie, error) { params := make(url.Values) if tmdbID != 0 { - params.Set("tmdbId", strconv.FormatInt(tmdbID, starr.Bits10)) + params.Set("tmdbId", strconv.FormatInt(tmdbID, starr.Base10)) } var movie []*Movie @@ -139,7 +139,7 @@ func (r *Radarr) GetMovie(tmdbID int64) ([]*Movie, error) { func (r *Radarr) GetMovieByID(movieID int64) (*Movie, error) { var movie Movie - err := r.GetInto("v3/movie/"+strconv.FormatInt(movieID, starr.Bits10), nil, &movie) + err := r.GetInto("v3/movie/"+strconv.FormatInt(movieID, starr.Base10), nil, &movie) if err != nil { return nil, fmt.Errorf("api.Get(movie): %w", err) } @@ -183,7 +183,7 @@ func (r *Radarr) UpdateQualityProfile(profile *QualityProfile) error { return fmt.Errorf("json.Marshal(profile): %w", err) } - _, err = r.Put("v3/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Bits10), nil, put) + _, err = r.Put("v3/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Base10), nil, put) if err != nil { return fmt.Errorf("api.Put(qualityProfile): %w", err) } @@ -213,7 +213,7 @@ func (r *Radarr) UpdateMovie(movieID int64, movie *Movie) error { params := make(url.Values) params.Add("moveFiles", "true") - _, err = r.Put("v3/movie/"+strconv.FormatInt(movieID, starr.Bits10), params, put) + _, err = r.Put("v3/movie/"+strconv.FormatInt(movieID, starr.Base10), params, put) if err != nil { return fmt.Errorf("api.Put(movie): %w", err) } @@ -259,7 +259,7 @@ func (r *Radarr) DeleteExclusions(ids []int64) error { var errs string for _, id := range ids { - _, err := r.Delete("v3/exclusions/"+strconv.FormatInt(id, starr.Bits10), nil) + _, err := r.Delete("v3/exclusions/"+strconv.FormatInt(id, starr.Base10), nil) if err != nil { errs += err.Error() + " " } @@ -373,7 +373,7 @@ func (r *Radarr) DeleteImportList(ids []int64) error { var errs string for _, id := range ids { - _, err := r.Delete("v3/importlist/"+strconv.FormatInt(id, starr.Bits10), nil) + _, err := r.Delete("v3/importlist/"+strconv.FormatInt(id, starr.Base10), nil) if err != nil { errs += fmt.Errorf("api.Delete(importlist): %w", err).Error() + " " } @@ -394,7 +394,7 @@ func (r *Radarr) UpdateImportList(il *ImportList) (*ImportList, error) { } var output ImportList - if err := r.PutInto("v3/importlist/"+strconv.FormatInt(il.ID, starr.Bits10), nil, body, &output); err != nil { + if err := r.PutInto("v3/importlist/"+strconv.FormatInt(il.ID, starr.Base10), nil, body, &output); err != nil { return nil, fmt.Errorf("api.Put(importlist): %w", err) } diff --git a/readarr/readarr.go b/readarr/readarr.go index 6602654..44d0983 100644 --- a/readarr/readarr.go +++ b/readarr/readarr.go @@ -144,7 +144,7 @@ func (r *Readarr) UpdateQualityProfile(profile *QualityProfile) error { return fmt.Errorf("json.Marshal(profile): %w", err) } - _, err = r.Put("v1/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Bits10), nil, put) + _, err = r.Put("v1/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Base10), nil, put) if err != nil { return fmt.Errorf("api.Put(qualityProfile): %w", err) } @@ -156,7 +156,7 @@ func (r *Readarr) UpdateQualityProfile(profile *QualityProfile) error { func (r *Readarr) GetAuthorByID(authorID int64) (*Author, error) { var author Author - err := r.GetInto("v1/author/"+strconv.FormatInt(authorID, starr.Bits10), nil, &author) + err := r.GetInto("v1/author/"+strconv.FormatInt(authorID, starr.Base10), nil, &author) if err != nil { return nil, fmt.Errorf("api.Get(author): %w", err) } @@ -174,7 +174,7 @@ func (r *Readarr) UpdateAuthor(authorID int64, author *Author) error { params := make(url.Values) params.Add("moveFiles", "true") - b, err := r.Put("v1/author/"+strconv.FormatInt(authorID, starr.Bits10), params, put) + b, err := r.Put("v1/author/"+strconv.FormatInt(authorID, starr.Base10), params, put) if err != nil { return fmt.Errorf("api.Put(author): %w", err) } @@ -206,7 +206,7 @@ func (r *Readarr) GetBook(gridID string) ([]*Book, error) { func (r *Readarr) GetBookByID(bookID int64) (*Book, error) { var book Book - err := r.GetInto("v1/book/"+strconv.FormatInt(bookID, starr.Bits10), nil, &book) + err := r.GetInto("v1/book/"+strconv.FormatInt(bookID, starr.Base10), nil, &book) if err != nil { return nil, fmt.Errorf("api.Get(book): %w", err) } @@ -224,7 +224,7 @@ func (r *Readarr) UpdateBook(bookID int64, book *Book) error { params := make(url.Values) params.Add("moveFiles", "true") - b, err := r.Put("v1/book/"+strconv.FormatInt(bookID, starr.Bits10), params, put) + b, err := r.Put("v1/book/"+strconv.FormatInt(bookID, starr.Base10), params, put) if err != nil { return fmt.Errorf("api.Put(book): %w", err) } diff --git a/shared.go b/shared.go index e527b6f..4487a9d 100644 --- a/shared.go +++ b/shared.go @@ -22,7 +22,7 @@ const ( // Silly constants to not screw up integer->string conversions. const ( - Bits10 = 10 + Base10 = 10 ) // String turns an App name into a string. diff --git a/sonarr/sonarr.go b/sonarr/sonarr.go index 9880970..fa84e14 100644 --- a/sonarr/sonarr.go +++ b/sonarr/sonarr.go @@ -139,7 +139,7 @@ func (s *Sonarr) UpdateQualityProfile(profile *QualityProfile) error { return fmt.Errorf("json.Marshal(profile): %w", err) } - _, err = s.Put("v3/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Bits10), nil, put) + _, err = s.Put("v3/qualityProfile/"+strconv.FormatInt(profile.ID, starr.Base10), nil, put) if err != nil { return fmt.Errorf("api.Put(qualityProfile): %w", err) } @@ -183,7 +183,7 @@ func (s *Sonarr) UpdateReleaseProfile(profile *ReleaseProfile) error { return fmt.Errorf("json.Marshal(profile): %w", err) } - _, err = s.Put("v3/releaseProfile/"+strconv.FormatInt(profile.ID, starr.Bits10), nil, put) + _, err = s.Put("v3/releaseProfile/"+strconv.FormatInt(profile.ID, starr.Base10), nil, put) if err != nil { return fmt.Errorf("api.Put(releaseProfile): %w", err) } @@ -209,7 +209,7 @@ func (s *Sonarr) GetSeriesLookup(term string, tvdbID int64) ([]*SeriesLookup, er params := make(url.Values) if tvdbID > 0 { - params.Add("term", "tvdbid:"+strconv.FormatInt(tvdbID, starr.Bits10)) + params.Add("term", "tvdbid:"+strconv.FormatInt(tvdbID, starr.Base10)) } else { params.Add("term", term) } @@ -229,7 +229,7 @@ func (s *Sonarr) GetSeries(tvdbID int64) ([]*Series, error) { params := make(url.Values) if tvdbID != 0 { - params.Add("tvdbId", strconv.FormatInt(tvdbID, starr.Bits10)) + params.Add("tvdbId", strconv.FormatInt(tvdbID, starr.Base10)) } var series []*Series @@ -246,7 +246,7 @@ func (s *Sonarr) GetSeries(tvdbID int64) ([]*Series, error) { func (s *Sonarr) GetSeriesByID(seriesID int64) (*Series, error) { var series Series - err := s.GetInto("v3/series/"+strconv.FormatInt(seriesID, starr.Bits10), nil, &series) + err := s.GetInto("v3/series/"+strconv.FormatInt(seriesID, starr.Base10), nil, &series) if err != nil { return nil, fmt.Errorf("api.Get(series): %w", err) } @@ -270,7 +270,7 @@ func (s *Sonarr) UpdateSeries(seriesID int64, series *Series) error { params := make(url.Values) params.Add("moveFiles", "true") - b, err := s.Put("v3/series/"+strconv.FormatInt(seriesID, starr.Bits10), params, put) + b, err := s.Put("v3/series/"+strconv.FormatInt(seriesID, starr.Base10), params, put) if err != nil { return fmt.Errorf("api.Put(series): %w", err) } @@ -330,13 +330,29 @@ func (s *Sonarr) SendCommand(cmd *CommandRequest) (*CommandResponse, error) { return &output, nil } +// GetCommandStatus returns the status of an already started command. +func (s *Sonarr) GetCommandStatus(commandID int64) (*CommandResponse, error) { + if commandID == 0 { + return nil, nil + } + + var output CommandResponse + + err := s.GetInto("v3/command/"+strconv.FormatInt(commandID, starr.Base10), nil, &output) + if err != nil { + return nil, fmt.Errorf("api.Post(command): %w", err) + } + + return &output, nil +} + // GetSeriesEpisodes returns all episodes for a series by series ID. // You can get series IDs from GetAllSeries() and GetSeries(). func (s *Sonarr) GetSeriesEpisodes(seriesID int64) ([]*Episode, error) { var output []*Episode params := make(url.Values) - params.Add("seriesId", strconv.FormatInt(seriesID, starr.Bits10)) + params.Add("seriesId", strconv.FormatInt(seriesID, starr.Base10)) err := s.GetInto("v3/episode?seriesId", params, &output) if err != nil { diff --git a/sonarr/type.go b/sonarr/type.go index 497cb0c..4eb3524 100644 --- a/sonarr/type.go +++ b/sonarr/type.go @@ -327,6 +327,7 @@ type AlternateTitle struct { // This was created from the search command and may not support other commands yet. type CommandRequest struct { Name string `json:"name"` + Files []int64 `json:"files,omitempty"` // RenameFiles only SeriesIDs []int64 `json:"seriesIds,omitempty"` SeriesID int64 `json:"seriesId,omitempty"` }