-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add rename endpoints #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package lidarr | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/url" | ||
|
|
||
| "golift.io/starr" | ||
| ) | ||
|
|
||
| const bpRename = APIver + "/rename" | ||
|
|
||
| // Rename is the /api/v1/rename endpoint. | ||
| type Rename struct { | ||
| ID int64 `json:"id"` | ||
| ArtistID int64 `json:"artistId"` | ||
| AlbumID int64 `json:"albumId"` | ||
| TrackNumbers []int64 `json:"trackNumbers"` | ||
| TrackFileID int64 `json:"trackFileId"` | ||
| ExistingPath string `json:"existingPath,omitempty"` | ||
| NewPath string `json:"newPath,omitempty"` | ||
| } | ||
|
|
||
| // GetRenames checks if the tracks by the specified artist (database ID) on the specified album (database ID) | ||
| // need to be renamed to follow the naming format. If albumID is set to -1, it will check all albums at once. | ||
| func (l *Lidarr) GetRenames(artistID int64, albumID int64) ([]*Rename, error) { | ||
| return l.GetRenamesContext(context.Background(), artistID, albumID) | ||
| } | ||
|
|
||
| // GetRenamesContext checks if the tracks by the specified artist (database ID) on the specified album (database ID) | ||
| // need to be renamed to follow the naming format. If albumID is set to -1, it will check all albums at once. | ||
| func (l *Lidarr) GetRenamesContext(ctx context.Context, artistID int64, albumID int64) ([]*Rename, error) { | ||
| params := make(url.Values) | ||
| params.Set("artistId", starr.Str(artistID)) | ||
|
|
||
| if albumID != -1 { | ||
davidnewhall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| params.Set("albumId", starr.Str(albumID)) | ||
| } | ||
|
|
||
| var output []*Rename | ||
|
|
||
| req := starr.Request{URI: bpRename, Query: params} | ||
| if err := l.GetInto(ctx, req, &output); err != nil { | ||
| return nil, fmt.Errorf("api.Get(%s): %w", &req, err) | ||
| } | ||
|
|
||
| return output, nil | ||
| } | ||
|
|
||
| // GetArtistRenames checks if the tracks by the specified artist (database ID) need to be renamed to | ||
| // follow the naming format. | ||
| func (l *Lidarr) GetArtistRenames(artistID int64) ([]*Rename, error) { | ||
| return l.GetRenamesContext(context.Background(), artistID, -1) | ||
| } | ||
|
|
||
| // GetArtistRenamesContext checks if the tracks by the specified artist (database ID) need to be renamed to | ||
| // follow the naming format. | ||
| func (l *Lidarr) GetArtistRenamesContext(ctx context.Context, artistID int64) ([]*Rename, error) { | ||
| return l.GetRenamesContext(ctx, artistID, -1) | ||
| } | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenames checks if any tracks need to be renamed to follow the naming format. | ||
| func (l *Lidarr) GetAllRenames() ([]*Rename, error) { | ||
| return l.GetRenamesContext(context.Background(), -1, -1) | ||
| } */ | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenamesContext checks if any tracks need to be renamed to follow the naming format. | ||
| func (l *Lidarr) GetAllRenamesContext(ctx context.Context) ([]*Rename, error) { | ||
| return l.GetRenamesContext(ctx, -1, -1) | ||
| } */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package radarr | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/url" | ||
|
|
||
| "golift.io/starr" | ||
| ) | ||
|
|
||
| const bpRename = APIver + "/rename" | ||
|
|
||
| // Rename is the /api/v3/rename endpoint. | ||
| type Rename struct { | ||
| ID int64 `json:"id"` | ||
| MovieID int64 `json:"movieId"` | ||
| MovieFileID int64 `json:"movieFileId"` | ||
| ExistingPath string `json:"existingPath,omitempty"` | ||
| NewPath string `json:"newPath,omitempty"` | ||
| } | ||
|
|
||
| // GetRenames checks if the movie with the specified movieID (database ID) needs to be renamed to | ||
| // follow the naming format. | ||
| func (r *Radarr) GetRenames(movieID int64) ([]*Rename, error) { | ||
| return r.GetRenamesContext(context.Background(), movieID) | ||
| } | ||
|
|
||
| // GetRenamesContext checks if the movie with the specified movieID (database ID) needs to be renamed to | ||
| // follow the naming format. | ||
| func (r *Radarr) GetRenamesContext(ctx context.Context, movieID int64) ([]*Rename, error) { | ||
| params := make(url.Values) | ||
| params.Set("movieId", starr.Str(movieID)) | ||
|
|
||
| var output []*Rename | ||
|
|
||
| req := starr.Request{URI: bpRename, Query: params} | ||
| if err := r.GetInto(ctx, req, &output); err != nil { | ||
| return nil, fmt.Errorf("api.Get(%s): %w", &req, err) | ||
| } | ||
|
|
||
| return output, nil | ||
| } | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenames checks if any movies need to be renamed to follow the naming format. | ||
| func (r *Radarr) GetAllRenames() ([]*Rename, error) { | ||
| return r.GetRenamesContext(context.Background(), -1) | ||
| } */ | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenamesContext checks if any movies need to be renamed to follow the naming format. | ||
| func (r *Radarr) GetAllRenamesContext(ctx context.Context) ([]*Rename, error) { | ||
| return r.GetRenamesContext(ctx, -1) | ||
| } */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package readarr | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/url" | ||
|
|
||
| "golift.io/starr" | ||
| ) | ||
|
|
||
| const bpRename = APIver + "/rename" | ||
|
|
||
| // Rename is the /api/v1/rename endpoint. | ||
| type Rename struct { | ||
| ID int64 `json:"id"` | ||
| AuthorID int64 `json:"authorId"` | ||
| BookID int64 `json:"bookId"` | ||
| BookFileID int64 `json:"bookFileId"` | ||
| ExistingPath string `json:"existingPath,omitempty"` | ||
| NewPath string `json:"newPath,omitempty"` | ||
| } | ||
|
|
||
| // GetRenames checks if the specified book (database ID) from the author (database ID) needs to be renamed to | ||
| // follow the naming format. If bookId is set to -1, it will check all books at once. | ||
| func (r *Readarr) GetRenames(authorID int64, bookID int64) ([]*Rename, error) { | ||
| return r.GetRenamesContext(context.Background(), authorID, bookID) | ||
| } | ||
|
|
||
| // GetRenamesContext checks if the specified book (database ID) from the author (database ID) needs to be renamed to | ||
| // follow the naming format. If bookId is set to -1, it will check all books at once. | ||
| func (r *Readarr) GetRenamesContext(ctx context.Context, authorID int64, bookID int64) ([]*Rename, error) { | ||
| params := make(url.Values) | ||
| params.Set("authorId", starr.Str(authorID)) | ||
|
|
||
| if bookID != -1 { | ||
| params.Set("bookId", starr.Str(bookID)) | ||
| } | ||
|
|
||
| var output []*Rename | ||
|
|
||
| req := starr.Request{URI: bpRename, Query: params} | ||
| if err := r.GetInto(ctx, req, &output); err != nil { | ||
| return nil, fmt.Errorf("api.Get(%s): %w", &req, err) | ||
| } | ||
|
|
||
| return output, nil | ||
| } | ||
|
|
||
| // GetAuthorRenames checks if the books from the specified author (database ID) need to be renamed to | ||
| // follow the naming format. | ||
| func (r *Readarr) GetAuthorRenames(authorID int64) ([]*Rename, error) { | ||
| return r.GetRenamesContext(context.Background(), authorID, -1) | ||
| } | ||
|
|
||
| // GetAuthorRenamesContext checks if the books from the specified author (database ID) need to be renamed to | ||
| // follow the naming format. | ||
| func (r *Readarr) GetAuthorRenamesContext(ctx context.Context, authorID int64) ([]*Rename, error) { | ||
| return r.GetRenamesContext(ctx, authorID, -1) | ||
| } | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenames checks if any books need to be renamed to follow the naming format. | ||
| func (r *Readarr) GetAllRenames() ([]*Rename, error) { | ||
| return r.GetRenamesContext(context.Background(), -1, -1) | ||
| } */ | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenamesContext checks if any books need to be renamed to follow the naming format. | ||
| func (r *Readarr) GetAllRenamesContext(ctx context.Context) ([]*Rename, error) { | ||
| return r.GetRenamesContext(ctx, -1, -1) | ||
| } */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package sonarr | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net/url" | ||
|
|
||
| "golift.io/starr" | ||
| ) | ||
|
|
||
| const bpRename = APIver + "/rename" | ||
|
|
||
| // Rename is the /api/v3/rename endpoint. | ||
| type Rename struct { | ||
| ID int64 `json:"id"` | ||
| SeriesID int64 `json:"seriesId"` | ||
| SeasonNumber int64 `json:"seasonNumber"` | ||
| EpisodeNumbers []int64 `json:"episodeNumbers"` | ||
| EpisodeFileID int64 `json:"episodeFileId"` | ||
| ExistingPath string `json:"existingPath,omitempty"` | ||
| NewPath string `json:"newPath,omitempty"` | ||
| } | ||
|
|
||
| // GetRenames checks if the episodes in the specified series (database ID) and season need to be renamed to | ||
| // follow the naming format. If seasonNumber is set to -1, it will check all seasons at once. | ||
| func (s *Sonarr) GetRenames(seriesID int64, seasonNumber int64) ([]*Rename, error) { | ||
| return s.GetRenamesContext(context.Background(), seriesID, seasonNumber) | ||
| } | ||
|
|
||
| // GetRenamesContext checks if the episodes in the specified series (database ID) and season need to be renamed to | ||
| // follow the naming format. If seasonNumber is set to -1, it will check all seasons at once. | ||
| func (s *Sonarr) GetRenamesContext(ctx context.Context, seriesID int64, seasonNumber int64) ([]*Rename, error) { | ||
| params := make(url.Values) | ||
| params.Set("seriesId", starr.Str(seriesID)) | ||
|
|
||
| if seasonNumber != -1 { | ||
| params.Set("seasonNumber", starr.Str(seasonNumber)) | ||
| } | ||
|
|
||
| var output []*Rename | ||
|
|
||
| req := starr.Request{URI: bpRename, Query: params} | ||
| if err := s.GetInto(ctx, req, &output); err != nil { | ||
| return nil, fmt.Errorf("api.Get(%s): %w", &req, err) | ||
| } | ||
|
|
||
| return output, nil | ||
| } | ||
|
|
||
| // GetSeriesRenames checks if the episodes in the specified series (database ID) need to be renamed to | ||
| // follow the naming format. | ||
| func (s *Sonarr) GetSeriesRenames(seriesID int64) ([]*Rename, error) { | ||
| return s.GetRenamesContext(context.Background(), seriesID, -1) | ||
| } | ||
|
|
||
| // GetSeriesRenamesContext checks if the episodes in the specified series (database ID) need to be renamed to | ||
| // follow the naming format. | ||
| func (s *Sonarr) GetSeriesRenamesContext(ctx context.Context, seriesID int64) ([]*Rename, error) { | ||
| return s.GetRenamesContext(ctx, seriesID, -1) | ||
| } | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenames checks if any episodes need to be renamed to follow the naming format. | ||
| func (s *Sonarr) GetAllRenames() ([]*Rename, error) { | ||
| return s.GetRenamesContext(context.Background(), -1, -1) | ||
| } */ | ||
|
|
||
| /* Doesn't exist yet | ||
| // GetAllRenamesContext checks if any episodes need to be renamed to follow the naming format. | ||
| func (s *Sonarr) GetAllRenamesContext(ctx context.Context) ([]*Rename, error) { | ||
| return s.GetRenamesContext(ctx, -1, -1) | ||
| } */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend running
golangci-linton this contribution.