From 512e1e9ee1957971a0e7c82b51401e4261197cfe Mon Sep 17 00:00:00 2001 From: David Newhall Date: Fri, 18 Mar 2022 03:55:52 -0700 Subject: [PATCH] Remove lidarr type file (#45) --- lidarr/album.go | 84 +++++++++++ lidarr/artist.go | 44 ++++++ lidarr/history.go | 47 ++++++ lidarr/lidarr.go | 119 +-------------- lidarr/metadataprofile.go | 46 ++++++ lidarr/qualitydefinition.go | 35 +++++ lidarr/qualityprofile.go | 9 ++ lidarr/queue.go | 105 +++++++++++++ lidarr/rootfolder.go | 34 +++++ lidarr/system.go | 30 ++++ lidarr/type.go | 293 ------------------------------------ 11 files changed, 437 insertions(+), 409 deletions(-) create mode 100644 lidarr/metadataprofile.go create mode 100644 lidarr/qualitydefinition.go create mode 100644 lidarr/queue.go create mode 100644 lidarr/rootfolder.go delete mode 100644 lidarr/type.go diff --git a/lidarr/album.go b/lidarr/album.go index 4dcc369..97a4734 100644 --- a/lidarr/album.go +++ b/lidarr/album.go @@ -7,10 +7,94 @@ import ( "fmt" "net/url" "strconv" + "time" "golift.io/starr" ) +// Album is the /api/v1/album endpoint. +type Album struct { + ID int64 `json:"id,omitempty"` + Title string `json:"title"` + Disambiguation string `json:"disambiguation"` + Overview string `json:"overview"` + ArtistID int64 `json:"artistId"` + ForeignAlbumID string `json:"foreignAlbumId"` + ProfileID int64 `json:"profileId"` + Duration int `json:"duration"` + AlbumType string `json:"albumType"` + SecondaryTypes []interface{} `json:"secondaryTypes"` + MediumCount int `json:"mediumCount"` + Ratings *starr.Ratings `json:"ratings"` + ReleaseDate time.Time `json:"releaseDate"` + Releases []*Release `json:"releases"` + Genres []interface{} `json:"genres"` + Media []*Media `json:"media"` + Artist *Artist `json:"artist"` + Links []*starr.Link `json:"links"` + Images []*starr.Image `json:"images"` + Statistics *Statistics `json:"statistics"` + RemoteCover string `json:"remoteCover,omitempty"` + AddOptions *AlbumAddOptions `json:"addOptions,omitempty"` + Monitored bool `json:"monitored"` + AnyReleaseOk bool `json:"anyReleaseOk"` + Grabbed bool `json:"grabbed"` +} + +// Release is part of an Album. +type Release struct { + ID int64 `json:"id"` + AlbumID int64 `json:"albumId"` + ForeignReleaseID string `json:"foreignReleaseId"` + Title string `json:"title"` + Status string `json:"status"` + Duration int `json:"duration"` + TrackCount int `json:"trackCount"` + Media []*Media `json:"media"` + MediumCount int `json:"mediumCount"` + Disambiguation string `json:"disambiguation"` + Country []string `json:"country"` + Label []string `json:"label"` + Format string `json:"format"` + Monitored bool `json:"monitored"` +} + +// Media is part of an Album. +type Media struct { + MediumNumber int64 `json:"mediumNumber"` + MediumName string `json:"mediumName"` + MediumFormat string `json:"mediumFormat"` +} + +// ArtistAddOptions is part of an artist and an album. +type ArtistAddOptions struct { + Monitor string `json:"monitor,omitempty"` + Monitored bool `json:"monitored,omitempty"` + SearchForMissingAlbums bool `json:"searchForMissingAlbums,omitempty"` +} + +// AddAlbumInput is currently unknown. +type AddAlbumInput struct { + ForeignAlbumID string `json:"foreignAlbumId"` + Monitored bool `json:"monitored"` + Releases []*AddAlbumInputRelease `json:"releases"` + AddOptions *AlbumAddOptions `json:"addOptions"` + Artist *Artist `json:"artist"` +} + +// AddAlbumInputRelease is part of AddAlbumInput. +type AddAlbumInputRelease struct { + ForeignReleaseID string `json:"foreignReleaseId"` + Title string `json:"title"` + Media []*Media `json:"media"` + Monitored bool `json:"monitored"` +} + +// AlbumAddOptions is part of an Album. +type AlbumAddOptions struct { + SearchForNewAlbum bool `json:"searchForNewAlbum,omitempty"` +} + // GetAlbum returns an album or all albums if mbID is "" (empty). // mbID is the music brainz UUID for a "release-group". func (l *Lidarr) GetAlbum(mbID string) ([]*Album, error) { diff --git a/lidarr/artist.go b/lidarr/artist.go index eca359c..16ddb3f 100644 --- a/lidarr/artist.go +++ b/lidarr/artist.go @@ -7,10 +7,54 @@ import ( "fmt" "net/url" "strconv" + "time" "golift.io/starr" ) +// Artist represents the /api/v1/artist endpoint, and it's part of an Album. +type Artist struct { + ID int64 `json:"id"` + Status string `json:"status,omitempty"` + LastInfoSync time.Time `json:"lastInfoSync,omitempty"` + ArtistName string `json:"artistName,omitempty"` + ForeignArtistID string `json:"foreignArtistId,omitempty"` + TadbID int64 `json:"tadbId,omitempty"` + DiscogsID int64 `json:"discogsId,omitempty"` + QualityProfileID int64 `json:"qualityProfileId,omitempty"` + MetadataProfileID int64 `json:"metadataProfileId,omitempty"` + Overview string `json:"overview,omitempty"` + ArtistType string `json:"artistType,omitempty"` + Disambiguation string `json:"disambiguation,omitempty"` + RootFolderPath string `json:"rootFolderPath,omitempty"` + Path string `json:"path,omitempty"` + CleanName string `json:"cleanName,omitempty"` + SortName string `json:"sortName,omitempty"` + Links []*starr.Link `json:"links,omitempty"` + Images []*starr.Image `json:"images,omitempty"` + Genres []string `json:"genres,omitempty"` + Tags []int `json:"tags,omitempty"` + Added time.Time `json:"added,omitempty"` + Ratings *starr.Ratings `json:"ratings,omitempty"` + Statistics *Statistics `json:"statistics,omitempty"` + LastAlbum *Album `json:"lastAlbum,omitempty"` + NextAlbum *Album `json:"nextAlbum,omitempty"` + AddOptions *ArtistAddOptions `json:"addOptions,omitempty"` + AlbumFolder bool `json:"albumFolder,omitempty"` + Monitored bool `json:"monitored"` + Ended bool `json:"ended,omitempty"` +} + +// Statistics is part of Artist and Album. +type Statistics struct { + AlbumCount int `json:"albumCount,omitempty"` + TrackFileCount int `json:"trackFileCount"` + TrackCount int `json:"trackCount"` + TotalTrackCount int `json:"totalTrackCount"` + SizeOnDisk int `json:"sizeOnDisk"` + PercentOfTracks float64 `json:"percentOfTracks"` +} + // GetArtist returns an artist or all artists. func (l *Lidarr) GetArtist(mbID string) ([]*Artist, error) { return l.GetArtistContext(context.Background(), mbID) diff --git a/lidarr/history.go b/lidarr/history.go index 88366d1..0d76bb2 100644 --- a/lidarr/history.go +++ b/lidarr/history.go @@ -5,10 +5,57 @@ import ( "context" "fmt" "strconv" + "time" "golift.io/starr" ) +// History represents the /api/v1/history endpoint. +type History struct { + Page int `json:"page"` + PageSize int `json:"pageSize"` + SortKey string `json:"sortKey"` + SortDirection string `json:"sortDirection"` + TotalRecords int `json:"totalRecords"` + Records []*HistoryRecord `json:"records"` +} + +// HistoryRecord is part of the history. Not all items have all Data members. +// Check EventType for events you need. +type HistoryRecord struct { + ID int64 `json:"id"` + AlbumID int64 `json:"albumId"` + ArtistID int64 `json:"artistId"` + TrackID int64 `json:"trackId"` + SourceTitle string `json:"sourceTitle"` + Quality *starr.Quality `json:"quality"` + QualityCutoffNotMet bool `json:"qualityCutoffNotMet"` + Date time.Time `json:"date"` + DownloadID string `json:"downloadId"` + EventType string `json:"eventType"` + Data struct { + Age string `json:"age"` + AgeHours string `json:"ageHours"` + AgeMinutes string `json:"ageMinutes"` + DownloadClient string `json:"downloadClient"` + DownloadForced string `json:"downloadForced"` + DownloadURL string `json:"downloadUrl"` + DroppedPath string `json:"droppedPath"` + GUID string `json:"guid"` + ImportedPath string `json:"importedPath"` + Indexer string `json:"indexer"` + Message string `json:"message"` + NzbInfoURL string `json:"nzbInfoUrl"` + Protocol string `json:"protocol"` + PublishedDate time.Time `json:"publishedDate"` + Reason string `json:"reason"` + ReleaseGroup string `json:"releaseGroup"` + Size string `json:"size"` + StatusMessages string `json:"statusMessages"` + TorrentInfoHash string `json:"torrentInfoHash"` + } `json:"data"` +} + // GetHistory returns the Lidarr History (grabs/failures/completed). // WARNING: 12/30/2021 - this method changed. // If you need control over the page, use lidarr.GetHistoryPage(). diff --git a/lidarr/lidarr.go b/lidarr/lidarr.go index 59d1c50..1bb6c53 100644 --- a/lidarr/lidarr.go +++ b/lidarr/lidarr.go @@ -1,14 +1,15 @@ package lidarr import ( - "context" "crypto/tls" - "fmt" "net/http" "golift.io/starr" ) +// APIver is the Lidarr API version supported by this library. +const APIver = "v1" + // Lidarr contains all the methods to interact with a Lidarr server. type Lidarr struct { starr.APIer @@ -52,117 +53,3 @@ func New(config *starr.Config) *Lidarr { return &Lidarr{APIer: config} } - -// GetQueue returns a single page from the Lidarr Queue (processing, but not yet imported). -// WARNING: 12/30/2021 - this method changed. -// If you need control over the page, use lidarr.GetQueuePage(). -// This function simply returns the number of queue records desired, -// up to the number of records present in the application. -// It grabs records in (paginated) batches of perPage, and concatenates -// them into one list. Passing zero for records will return all of them. -func (l *Lidarr) GetQueue(records, perPage int) (*Queue, error) { - return l.GetQueueContext(context.Background(), records, perPage) -} - -// GetQueueContext returns a single page from the Lidarr Queue (processing, but not yet imported). -func (l *Lidarr) GetQueueContext(ctx context.Context, records, perPage int) (*Queue, error) { - queue := &Queue{Records: []*QueueRecord{}} - perPage = starr.SetPerPage(records, perPage) - - for page := 1; ; page++ { - curr, err := l.GetQueuePageContext(ctx, &starr.Req{PageSize: perPage, Page: page}) - if err != nil { - return nil, err - } - - queue.Records = append(queue.Records, curr.Records...) - - if len(queue.Records) >= curr.TotalRecords || - (len(queue.Records) >= records && records != 0) || - len(curr.Records) == 0 { - queue.PageSize = curr.TotalRecords - queue.TotalRecords = curr.TotalRecords - queue.SortDirection = curr.SortDirection - queue.SortKey = curr.SortKey - - break - } - - perPage = starr.AdjustPerPage(records, curr.TotalRecords, len(queue.Records), perPage) - } - - return queue, nil -} - -// GetQueuePage returns a single page from the Lidarr Queue. -// The page size and number is configurable with the input request parameters. -func (l *Lidarr) GetQueuePage(params *starr.Req) (*Queue, error) { - return l.GetQueuePageContext(context.Background(), params) -} - -// GetQueuePageContext returns a single page from the Lidarr Queue. -// The page size and number is configurable with the input request parameters. -func (l *Lidarr) GetQueuePageContext(ctx context.Context, params *starr.Req) (*Queue, error) { - var queue Queue - - params.CheckSet("sortKey", "timeleft") - params.CheckSet("includeUnknownArtistItems", "true") - - _, err := l.GetInto(ctx, "v1/queue", params.Params(), &queue) - if err != nil { - return nil, fmt.Errorf("api.Get(queue): %w", err) - } - - return &queue, nil -} - -// GetQualityDefinition returns the Quality Definitions. -func (l *Lidarr) GetQualityDefinition() ([]*QualityDefinition, error) { - return l.GetQualityDefinitionContext(context.Background()) -} - -// GetQualityDefinitionContext returns the Quality Definitions. -func (l *Lidarr) GetQualityDefinitionContext(ctx context.Context) ([]*QualityDefinition, error) { - var definition []*QualityDefinition - - _, err := l.GetInto(ctx, "v1/qualitydefinition", nil, &definition) - if err != nil { - return nil, fmt.Errorf("api.Get(qualitydefinition): %w", err) - } - - return definition, nil -} - -// GetRootFolders returns all configured root folders. -func (l *Lidarr) GetRootFolders() ([]*RootFolder, error) { - return l.GetRootFoldersContext(context.Background()) -} - -// GetRootFoldersContext returns all configured root folders. -func (l *Lidarr) GetRootFoldersContext(ctx context.Context) ([]*RootFolder, error) { - var folders []*RootFolder - - _, err := l.GetInto(ctx, "v1/rootFolder", nil, &folders) - if err != nil { - return nil, fmt.Errorf("api.Get(rootFolder): %w", err) - } - - return folders, nil -} - -// GetMetadataProfiles returns the metadata profiles. -func (l *Lidarr) GetMetadataProfiles() ([]*MetadataProfile, error) { - return l.GetMetadataProfilesContext(context.Background()) -} - -// GetMetadataProfilesContext returns the metadata profiles. -func (l *Lidarr) GetMetadataProfilesContext(ctx context.Context) ([]*MetadataProfile, error) { - var profiles []*MetadataProfile - - _, err := l.GetInto(ctx, "v1/metadataprofile", nil, &profiles) - if err != nil { - return nil, fmt.Errorf("api.Get(metadataprofile): %w", err) - } - - return profiles, nil -} diff --git a/lidarr/metadataprofile.go b/lidarr/metadataprofile.go new file mode 100644 index 0000000..e8a1118 --- /dev/null +++ b/lidarr/metadataprofile.go @@ -0,0 +1,46 @@ +package lidarr + +import ( + "context" + "fmt" + + "golift.io/starr" +) + +// MetadataProfile is the /api/v1/metadataprofile endpoint. +type MetadataProfile struct { + Name string `json:"name"` + ID int64 `json:"id"` + PrimaryAlbumTypes []*AlbumType `json:"primaryAlbumTypes"` + SecondaryAlbumTypes []*AlbumType `json:"secondaryAlbumTypes"` + ReleaseStatuses []*ReleaseStatus `json:"releaseStatuses"` +} + +// AlbumType is part of MetadataProfile. +type AlbumType struct { + AlbumType *starr.Value `json:"albumType"` + Allowed bool `json:"allowed"` +} + +// ReleaseStatus is part of MetadataProfile. +type ReleaseStatus struct { + ReleaseStatus *starr.Value `json:"releaseStatus"` + Allowed bool `json:"allowed"` +} + +// GetMetadataProfiles returns the metadata profiles. +func (l *Lidarr) GetMetadataProfiles() ([]*MetadataProfile, error) { + return l.GetMetadataProfilesContext(context.Background()) +} + +// GetMetadataProfilesContext returns the metadata profiles. +func (l *Lidarr) GetMetadataProfilesContext(ctx context.Context) ([]*MetadataProfile, error) { + var profiles []*MetadataProfile + + _, err := l.GetInto(ctx, "v1/metadataprofile", nil, &profiles) + if err != nil { + return nil, fmt.Errorf("api.Get(metadataprofile): %w", err) + } + + return profiles, nil +} diff --git a/lidarr/qualitydefinition.go b/lidarr/qualitydefinition.go new file mode 100644 index 0000000..0e04e22 --- /dev/null +++ b/lidarr/qualitydefinition.go @@ -0,0 +1,35 @@ +package lidarr + +import ( + "context" + "fmt" + + "golift.io/starr" +) + +// QualityDefinition is the /api/v1/qualitydefinition endpoint. +type QualityDefinition struct { + ID int64 `json:"id"` + Quality *starr.Value `json:"quality"` + Title string `json:"title"` + Weight int64 `json:"weight"` + MinSize float64 `json:"minSize"` + MaxSize float64 `json:"maxSize,omitempty"` +} + +// GetQualityDefinition returns the Quality Definitions. +func (l *Lidarr) GetQualityDefinition() ([]*QualityDefinition, error) { + return l.GetQualityDefinitionContext(context.Background()) +} + +// GetQualityDefinitionContext returns the Quality Definitions. +func (l *Lidarr) GetQualityDefinitionContext(ctx context.Context) ([]*QualityDefinition, error) { + var definition []*QualityDefinition + + _, err := l.GetInto(ctx, "v1/qualitydefinition", nil, &definition) + if err != nil { + return nil, fmt.Errorf("api.Get(qualitydefinition): %w", err) + } + + return definition, nil +} diff --git a/lidarr/qualityprofile.go b/lidarr/qualityprofile.go index 53dac2b..6392a18 100644 --- a/lidarr/qualityprofile.go +++ b/lidarr/qualityprofile.go @@ -10,6 +10,15 @@ import ( "golift.io/starr" ) +// QualityProfile is the /api/v1/qualityprofile endpoint. +type QualityProfile struct { + ID int64 `json:"id"` + Name string `json:"name"` + UpgradeAllowed bool `json:"upgradeAllowed"` + Cutoff int64 `json:"cutoff"` + Qualities []*starr.Quality `json:"items"` +} + // GetQualityProfiles returns the quality profiles. func (l *Lidarr) GetQualityProfiles() ([]*QualityProfile, error) { return l.GetQualityProfilesContext(context.Background()) diff --git a/lidarr/queue.go b/lidarr/queue.go new file mode 100644 index 0000000..fb68a2b --- /dev/null +++ b/lidarr/queue.go @@ -0,0 +1,105 @@ +package lidarr + +import ( + "context" + "fmt" + "time" + + "golift.io/starr" +) + +// Queue is the /api/v1/queue endpoint. +type Queue struct { + Page int `json:"page"` + PageSize int `json:"pageSize"` + SortKey string `json:"sortKey"` + SortDirection string `json:"sortDirection"` + TotalRecords int `json:"totalRecords"` + Records []*QueueRecord `json:"records"` +} + +// QueueRecord represents the records returns by the /api/v1/queue endpoint. +type QueueRecord struct { + ArtistID int64 `json:"artistId"` + AlbumID int64 `json:"albumId"` + Quality *starr.Quality `json:"quality"` + Size float64 `json:"size"` + Title string `json:"title"` + Sizeleft float64 `json:"sizeleft"` + Timeleft string `json:"timeleft"` + EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"` + Status string `json:"status"` + TrackedDownloadStatus string `json:"trackedDownloadStatus"` + StatusMessages []*starr.StatusMessage `json:"statusMessages"` + DownloadID string `json:"downloadId"` + Protocol string `json:"protocol"` + DownloadClient string `json:"downloadClient"` + Indexer string `json:"indexer"` + OutputPath string `json:"outputPath"` + DownloadForced bool `json:"downloadForced"` + ID int64 `json:"id"` + ErrorMessage string `json:"errorMessage"` +} + +// GetQueue returns a single page from the Lidarr Queue (processing, but not yet imported). +// WARNING: 12/30/2021 - this method changed. +// If you need control over the page, use lidarr.GetQueuePage(). +// This function simply returns the number of queue records desired, +// up to the number of records present in the application. +// It grabs records in (paginated) batches of perPage, and concatenates +// them into one list. Passing zero for records will return all of them. +func (l *Lidarr) GetQueue(records, perPage int) (*Queue, error) { + return l.GetQueueContext(context.Background(), records, perPage) +} + +// GetQueueContext returns a single page from the Lidarr Queue (processing, but not yet imported). +func (l *Lidarr) GetQueueContext(ctx context.Context, records, perPage int) (*Queue, error) { + queue := &Queue{Records: []*QueueRecord{}} + perPage = starr.SetPerPage(records, perPage) + + for page := 1; ; page++ { + curr, err := l.GetQueuePageContext(ctx, &starr.Req{PageSize: perPage, Page: page}) + if err != nil { + return nil, err + } + + queue.Records = append(queue.Records, curr.Records...) + + if len(queue.Records) >= curr.TotalRecords || + (len(queue.Records) >= records && records != 0) || + len(curr.Records) == 0 { + queue.PageSize = curr.TotalRecords + queue.TotalRecords = curr.TotalRecords + queue.SortDirection = curr.SortDirection + queue.SortKey = curr.SortKey + + break + } + + perPage = starr.AdjustPerPage(records, curr.TotalRecords, len(queue.Records), perPage) + } + + return queue, nil +} + +// GetQueuePage returns a single page from the Lidarr Queue. +// The page size and number is configurable with the input request parameters. +func (l *Lidarr) GetQueuePage(params *starr.Req) (*Queue, error) { + return l.GetQueuePageContext(context.Background(), params) +} + +// GetQueuePageContext returns a single page from the Lidarr Queue. +// The page size and number is configurable with the input request parameters. +func (l *Lidarr) GetQueuePageContext(ctx context.Context, params *starr.Req) (*Queue, error) { + var queue Queue + + params.CheckSet("sortKey", "timeleft") + params.CheckSet("includeUnknownArtistItems", "true") + + _, err := l.GetInto(ctx, "v1/queue", params.Params(), &queue) + if err != nil { + return nil, fmt.Errorf("api.Get(queue): %w", err) + } + + return &queue, nil +} diff --git a/lidarr/rootfolder.go b/lidarr/rootfolder.go new file mode 100644 index 0000000..d0e69f7 --- /dev/null +++ b/lidarr/rootfolder.go @@ -0,0 +1,34 @@ +package lidarr + +import ( + "context" + "fmt" + + "golift.io/starr" +) + +// RootFolder is the /api/v1/rootfolder endpoint. +type RootFolder struct { + ID int64 `json:"id"` + Path string `json:"path"` + FreeSpace int64 `json:"freeSpace"` + TotalSpace int64 `json:"totalSpace"` + UnmappedFolders []*starr.Path `json:"unmappedFolders"` +} + +// GetRootFolders returns all configured root folders. +func (l *Lidarr) GetRootFolders() ([]*RootFolder, error) { + return l.GetRootFoldersContext(context.Background()) +} + +// GetRootFoldersContext returns all configured root folders. +func (l *Lidarr) GetRootFoldersContext(ctx context.Context) ([]*RootFolder, error) { + var folders []*RootFolder + + _, err := l.GetInto(ctx, "v1/rootFolder", nil, &folders) + if err != nil { + return nil, fmt.Errorf("api.Get(rootFolder): %w", err) + } + + return folders, nil +} diff --git a/lidarr/system.go b/lidarr/system.go index 45dc62e..75da32c 100644 --- a/lidarr/system.go +++ b/lidarr/system.go @@ -3,10 +3,40 @@ package lidarr import ( "context" "fmt" + "time" "golift.io/starr" ) +// SystemStatus is the /api/v1/system/status endpoint. +type SystemStatus struct { + Version string `json:"version"` + BuildTime time.Time `json:"buildTime"` + IsDebug bool `json:"isDebug"` + IsProduction bool `json:"isProduction"` + IsAdmin bool `json:"isAdmin"` + IsUserInteractive bool `json:"isUserInteractive"` + StartupPath string `json:"startupPath"` + AppData string `json:"appData"` + OsName string `json:"osName"` + OsVersion string `json:"osVersion"` + IsMonoRuntime bool `json:"isMonoRuntime"` + IsMono bool `json:"isMono"` + IsLinux bool `json:"isLinux"` + IsOsx bool `json:"isOsx"` + IsWindows bool `json:"isWindows"` + IsDocker bool `json:"isDocker"` + Mode string `json:"mode"` + Branch string `json:"branch"` + Authentication string `json:"authentication"` + SqliteVersion string `json:"sqliteVersion"` + MigrationVersion int64 `json:"migrationVersion"` + URLBase string `json:"urlBase"` + RuntimeVersion string `json:"runtimeVersion"` + RuntimeName string `json:"runtimeName"` + StartTime time.Time `json:"startTime"` +} + // GetSystemStatus returns system status. func (l *Lidarr) GetSystemStatus() (*SystemStatus, error) { return l.GetSystemStatusContext(context.Background()) diff --git a/lidarr/type.go b/lidarr/type.go deleted file mode 100644 index 17db314..0000000 --- a/lidarr/type.go +++ /dev/null @@ -1,293 +0,0 @@ -package lidarr - -import ( - "time" - - "golift.io/starr" -) - -// APIver is the Lidarr API version supported by this library. -const APIver = "v1" - -// Queue is the /api/v1/queue endpoint. -type Queue struct { - Page int `json:"page"` - PageSize int `json:"pageSize"` - SortKey string `json:"sortKey"` - SortDirection string `json:"sortDirection"` - TotalRecords int `json:"totalRecords"` - Records []*QueueRecord `json:"records"` -} - -// QueueRecord represents the records returns by the /api/v1/queue endpoint. -type QueueRecord struct { - ArtistID int64 `json:"artistId"` - AlbumID int64 `json:"albumId"` - Quality *starr.Quality `json:"quality"` - Size float64 `json:"size"` - Title string `json:"title"` - Sizeleft float64 `json:"sizeleft"` - Timeleft string `json:"timeleft"` - EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"` - Status string `json:"status"` - TrackedDownloadStatus string `json:"trackedDownloadStatus"` - StatusMessages []*starr.StatusMessage `json:"statusMessages"` - DownloadID string `json:"downloadId"` - Protocol string `json:"protocol"` - DownloadClient string `json:"downloadClient"` - Indexer string `json:"indexer"` - OutputPath string `json:"outputPath"` - DownloadForced bool `json:"downloadForced"` - ID int64 `json:"id"` - ErrorMessage string `json:"errorMessage"` -} - -// QualityProfile is the /api/v1/qualityprofile endpoint. -type QualityProfile struct { - ID int64 `json:"id"` - Name string `json:"name"` - UpgradeAllowed bool `json:"upgradeAllowed"` - Cutoff int64 `json:"cutoff"` - Qualities []*starr.Quality `json:"items"` -} - -// MetadataProfile is the /api/v1/metadataprofile endpoint. -type MetadataProfile struct { - Name string `json:"name"` - ID int64 `json:"id"` - PrimaryAlbumTypes []*AlbumType `json:"primaryAlbumTypes"` - SecondaryAlbumTypes []*AlbumType `json:"secondaryAlbumTypes"` - ReleaseStatuses []*ReleaseStatus `json:"releaseStatuses"` -} - -// AlbumType is part of MetadataProfile. -type AlbumType struct { - AlbumType *starr.Value `json:"albumType"` - Allowed bool `json:"allowed"` -} - -// ReleaseStatus is part of MetadataProfile. -type ReleaseStatus struct { - ReleaseStatus *starr.Value `json:"releaseStatus"` - Allowed bool `json:"allowed"` -} - -// RootFolder is the /api/v1/rootfolder endpoint. -type RootFolder struct { - ID int64 `json:"id"` - Path string `json:"path"` - FreeSpace int64 `json:"freeSpace"` - TotalSpace int64 `json:"totalSpace"` - UnmappedFolders []*starr.Path `json:"unmappedFolders"` -} - -// QualityDefinition is the /api/v1/qualitydefinition endpoint. -type QualityDefinition struct { - ID int64 `json:"id"` - Quality *starr.Value `json:"quality"` - Title string `json:"title"` - Weight int64 `json:"weight"` - MinSize float64 `json:"minSize"` - MaxSize float64 `json:"maxSize,omitempty"` -} - -// SystemStatus is the /api/v1/system/status endpoint. -type SystemStatus struct { - Version string `json:"version"` - BuildTime time.Time `json:"buildTime"` - IsDebug bool `json:"isDebug"` - IsProduction bool `json:"isProduction"` - IsAdmin bool `json:"isAdmin"` - IsUserInteractive bool `json:"isUserInteractive"` - StartupPath string `json:"startupPath"` - AppData string `json:"appData"` - OsName string `json:"osName"` - OsVersion string `json:"osVersion"` - IsMonoRuntime bool `json:"isMonoRuntime"` - IsMono bool `json:"isMono"` - IsLinux bool `json:"isLinux"` - IsOsx bool `json:"isOsx"` - IsWindows bool `json:"isWindows"` - IsDocker bool `json:"isDocker"` - Mode string `json:"mode"` - Branch string `json:"branch"` - Authentication string `json:"authentication"` - SqliteVersion string `json:"sqliteVersion"` - MigrationVersion int64 `json:"migrationVersion"` - URLBase string `json:"urlBase"` - RuntimeVersion string `json:"runtimeVersion"` - RuntimeName string `json:"runtimeName"` - StartTime time.Time `json:"startTime"` -} - -// Artist represents the /api/v1/artist endpoint, and it's part of an Album. -type Artist struct { - ID int64 `json:"id"` - Status string `json:"status,omitempty"` - LastInfoSync time.Time `json:"lastInfoSync,omitempty"` - ArtistName string `json:"artistName,omitempty"` - ForeignArtistID string `json:"foreignArtistId,omitempty"` - TadbID int64 `json:"tadbId,omitempty"` - DiscogsID int64 `json:"discogsId,omitempty"` - QualityProfileID int64 `json:"qualityProfileId,omitempty"` - MetadataProfileID int64 `json:"metadataProfileId,omitempty"` - Overview string `json:"overview,omitempty"` - ArtistType string `json:"artistType,omitempty"` - Disambiguation string `json:"disambiguation,omitempty"` - RootFolderPath string `json:"rootFolderPath,omitempty"` - Path string `json:"path,omitempty"` - CleanName string `json:"cleanName,omitempty"` - SortName string `json:"sortName,omitempty"` - Links []*starr.Link `json:"links,omitempty"` - Images []*starr.Image `json:"images,omitempty"` - Genres []string `json:"genres,omitempty"` - Tags []int `json:"tags,omitempty"` - Added time.Time `json:"added,omitempty"` - Ratings *starr.Ratings `json:"ratings,omitempty"` - Statistics *Statistics `json:"statistics,omitempty"` - LastAlbum *Album `json:"lastAlbum,omitempty"` - NextAlbum *Album `json:"nextAlbum,omitempty"` - AddOptions *ArtistAddOptions `json:"addOptions,omitempty"` - AlbumFolder bool `json:"albumFolder,omitempty"` - Monitored bool `json:"monitored"` - Ended bool `json:"ended,omitempty"` -} - -// Statistics is part of Artist. -type Statistics struct { - AlbumCount int `json:"albumCount,omitempty"` - TrackFileCount int `json:"trackFileCount"` - TrackCount int `json:"trackCount"` - TotalTrackCount int `json:"totalTrackCount"` - SizeOnDisk int `json:"sizeOnDisk"` - PercentOfTracks float64 `json:"percentOfTracks"` -} - -// Album is the /api/v1/album endpoint. -type Album struct { - ID int64 `json:"id,omitempty"` - Title string `json:"title"` - Disambiguation string `json:"disambiguation"` - Overview string `json:"overview"` - ArtistID int64 `json:"artistId"` - ForeignAlbumID string `json:"foreignAlbumId"` - ProfileID int64 `json:"profileId"` - Duration int `json:"duration"` - AlbumType string `json:"albumType"` - SecondaryTypes []interface{} `json:"secondaryTypes"` - MediumCount int `json:"mediumCount"` - Ratings *starr.Ratings `json:"ratings"` - ReleaseDate time.Time `json:"releaseDate"` - Releases []*Release `json:"releases"` - Genres []interface{} `json:"genres"` - Media []*Media `json:"media"` - Artist *Artist `json:"artist"` - Links []*starr.Link `json:"links"` - Images []*starr.Image `json:"images"` - Statistics *Statistics `json:"statistics"` - RemoteCover string `json:"remoteCover,omitempty"` - AddOptions *AlbumAddOptions `json:"addOptions,omitempty"` - Monitored bool `json:"monitored"` - AnyReleaseOk bool `json:"anyReleaseOk"` - Grabbed bool `json:"grabbed"` -} - -// Release is part of an Album. -type Release struct { - ID int64 `json:"id"` - AlbumID int64 `json:"albumId"` - ForeignReleaseID string `json:"foreignReleaseId"` - Title string `json:"title"` - Status string `json:"status"` - Duration int `json:"duration"` - TrackCount int `json:"trackCount"` - Media []*Media `json:"media"` - MediumCount int `json:"mediumCount"` - Disambiguation string `json:"disambiguation"` - Country []string `json:"country"` - Label []string `json:"label"` - Format string `json:"format"` - Monitored bool `json:"monitored"` -} - -// Media is part of an Album. -type Media struct { - MediumNumber int64 `json:"mediumNumber"` - MediumName string `json:"mediumName"` - MediumFormat string `json:"mediumFormat"` -} - -// ArtistAddOptions is part of an artist and an album. -type ArtistAddOptions struct { - Monitor string `json:"monitor,omitempty"` - Monitored bool `json:"monitored,omitempty"` - SearchForMissingAlbums bool `json:"searchForMissingAlbums,omitempty"` -} - -// AddAlbumInput is currently unknown. -type AddAlbumInput struct { - ForeignAlbumID string `json:"foreignAlbumId"` - Monitored bool `json:"monitored"` - Releases []*AddAlbumInputRelease `json:"releases"` - AddOptions *AlbumAddOptions `json:"addOptions"` - Artist *Artist `json:"artist"` -} - -// AddAlbumInputRelease is part of AddAlbumInput. -type AddAlbumInputRelease struct { - ForeignReleaseID string `json:"foreignReleaseId"` - Title string `json:"title"` - Media []*Media `json:"media"` - Monitored bool `json:"monitored"` -} - -// AlbumAddOptions is part of an Album. -type AlbumAddOptions struct { - SearchForNewAlbum bool `json:"searchForNewAlbum,omitempty"` -} - -// History represents the /api/v1/history endpoint. -type History struct { - Page int `json:"page"` - PageSize int `json:"pageSize"` - SortKey string `json:"sortKey"` - SortDirection string `json:"sortDirection"` - TotalRecords int `json:"totalRecords"` - Records []*HistoryRecord `json:"records"` -} - -// HistoryRecord is part of the history. Not all items have all Data members. -// Check EventType for events you need. -type HistoryRecord struct { - ID int64 `json:"id"` - AlbumID int64 `json:"albumId"` - ArtistID int64 `json:"artistId"` - TrackID int64 `json:"trackId"` - SourceTitle string `json:"sourceTitle"` - Quality *starr.Quality `json:"quality"` - QualityCutoffNotMet bool `json:"qualityCutoffNotMet"` - Date time.Time `json:"date"` - DownloadID string `json:"downloadId"` - EventType string `json:"eventType"` - Data struct { - Age string `json:"age"` - AgeHours string `json:"ageHours"` - AgeMinutes string `json:"ageMinutes"` - DownloadClient string `json:"downloadClient"` - DownloadForced string `json:"downloadForced"` - DownloadURL string `json:"downloadUrl"` - DroppedPath string `json:"droppedPath"` - GUID string `json:"guid"` - ImportedPath string `json:"importedPath"` - Indexer string `json:"indexer"` - Message string `json:"message"` - NzbInfoURL string `json:"nzbInfoUrl"` - Protocol string `json:"protocol"` - PublishedDate time.Time `json:"publishedDate"` - Reason string `json:"reason"` - ReleaseGroup string `json:"releaseGroup"` - Size string `json:"size"` - StatusMessages string `json:"statusMessages"` - TorrentInfoHash string `json:"torrentInfoHash"` - } `json:"data"` -}