-
Notifications
You must be signed in to change notification settings - Fork 18
/
radarr.go
210 lines (194 loc) · 7.52 KB
/
radarr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package starr
import (
"encoding/json"
"fmt"
"net/url"
"time"
)
// RadarHistory is the /api/history endpoint.
type RadarHistory struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
SortKey string `json:"sortKey"`
SortDirection string `json:"sortDirection"`
TotalRecords int64 `json:"totalRecords"`
Records []*RadarRecord `json:"Records"`
}
// RadarRecord is a record in Radarr History
type RadarRecord struct {
EpisodeID int64 `json:"episodeId"`
MovieID int64 `json:"movieId"`
SeriesID int64 `json:"seriesId"`
SourceTitle string `json:"sourceTitle"`
Quality struct {
Quality struct {
ID int64 `json:"id"`
Name string `json:"name"`
} `json:"quality"`
Revision struct {
Version int64 `json:"version"`
Real int64 `json:"real"`
} `json:"revision"`
} `json:"quality"`
QualityCutoffNotMet bool `json:"qualityCutoffNotMet"`
Date time.Time `json:"date"`
DownloadID string `json:"downloadId"`
EventType string `json:"eventType"`
Data struct {
Indexer string `json:"indexer"`
NzbInfoURL string `json:"nzbInfoUrl"`
ReleaseGroup string `json:"releaseGroup"`
Age string `json:"age"`
AgeHours string `json:"ageHours"`
AgeMinutes string `json:"ageMinutes"`
PublishedDate time.Time `json:"publishedDate"`
DownloadClient string `json:"downloadClient"`
Size string `json:"size"`
DownloadURL string `json:"downloadUrl"`
GUID string `json:"guid"`
TvdbID string `json:"tvdbId"`
TvRageID string `json:"tvRageId"`
Protocol string `json:"protocol"`
TorrentInfoHash []string `json:"torrentInfoHash"`
} `json:"data"`
Movie struct {
Downloaded bool `json:"downloaded"`
Monitored bool `json:"monitored"`
HasFile bool `json:"hasFile"`
Year int `json:"year"`
ProfileID int `json:"profileId"`
Runtime int `json:"runtime"`
QualityProfileID int `json:"qualityProfileId"`
ID int64 `json:"id"`
SizeOnDisk int64 `json:"sizeOnDisk"`
Title string `json:"title"`
SortTitle string `json:"sortTitle"`
Status string `json:"status"`
Overview string `json:"overview"`
InCinemas time.Time `json:"inCinemas"`
Images []struct {
CoverType string `json:"coverType"`
URL string `json:"url"`
} `json:"images"`
Website string `json:"website"`
YouTubeTrailerID string `json:"youTubeTrailerId"`
Studio string `json:"studio"`
Path string `json:"path"`
LastInfoSync time.Time `json:"lastInfoSync"`
CleanTitle string `json:"cleanTitle"`
ImdbID string `json:"imdbId"`
TmdbID int64 `json:"tmdbId"`
TitleSlug string `json:"titleSlug"`
Genres []string `json:"genres"`
Tags []interface{} `json:"tags"`
Added time.Time `json:"added"`
Ratings struct {
Votes int64 `json:"votes"`
Value float64 `json:"value"`
} `json:"ratings"`
AlternativeTitles []string `json:"alternativeTitles"`
} `json:"movie"`
ID int `json:"id"`
}
// RadarQueue is the /api/queue endpoint.
type RadarQueue struct {
ID int64 `json:"id"`
Size float64 `json:"size"`
Sizeleft float64 `json:"sizeleft"`
EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"`
Title string `json:"title"`
Timeleft string `json:"timeleft"`
Status string `json:"status"`
TrackedDownloadStatus string `json:"trackedDownloadStatus"`
DownloadID string `json:"downloadId"`
Protocol string `json:"protocol"`
Movie struct {
Downloaded bool `json:"downloaded"`
HasFile bool `json:"hasFile"`
Monitored bool `json:"monitored"`
IsAvailable bool `json:"isAvailable"`
SecondaryYearSourceID int `json:"secondaryYearSourceId"`
Year int `json:"year"`
ProfileID int `json:"profileId"`
Runtime int `json:"runtime"`
QualityProfileID int64 `json:"qualityProfileId"`
ID int64 `json:"id"`
TmdbID int64 `json:"tmdbId"`
SizeOnDisk int64 `json:"sizeOnDisk"`
InCinemas time.Time `json:"inCinemas"`
PhysicalRelease time.Time `json:"physicalRelease"`
LastInfoSync time.Time `json:"lastInfoSync"`
Added time.Time `json:"added"`
Title string `json:"title"`
SortTitle string `json:"sortTitle"`
Status string `json:"status"`
Overview string `json:"overview"`
Website string `json:"website"`
YouTubeTrailerID string `json:"youTubeTrailerId"`
Studio string `json:"studio"`
Path string `json:"path"`
PathState string `json:"pathState"`
MinimumAvailability string `json:"minimumAvailability"`
FolderName string `json:"folderName"`
CleanTitle string `json:"cleanTitle"`
ImdbID string `json:"imdbId"`
TitleSlug string `json:"titleSlug"`
Genres []string `json:"genres"`
Tags []interface{} `json:"tags"`
AlternativeTitles []interface{} `json:"alternativeTitles"`
Images []struct {
CoverType string `json:"coverType"`
URL string `json:"url"`
} `json:"images"`
Ratings struct {
Votes int64 `json:"votes"`
Value float64 `json:"value"`
} `json:"ratings"`
} `json:"movie"`
Quality struct {
Quality struct {
ID int64 `json:"id"`
Name string `json:"name"`
} `json:"quality"`
Revision struct {
Version int64 `json:"version"`
Real int64 `json:"real"`
} `json:"revision"`
} `json:"quality"`
StatusMessages []struct {
Title string `json:"title"`
Messages []string `json:"messages"`
} `json:"statusMessages"`
}
// RadarrHistory returns the Radarr History (grabs/failures/completed)
func (c *Config) RadarrHistory() ([]*RadarRecord, error) {
var history RadarHistory
params := make(url.Values)
params.Set("sortKey", "date")
params.Set("sortDir", "asc")
params.Set("page", "1")
params.Set("pageSize", "0")
rawJSON, err := c.Req("history", params)
if err != nil {
return nil, fmt.Errorf("c.Req(queue): %v", err)
}
if err = json.Unmarshal(rawJSON, &history); err != nil {
return nil, fmt.Errorf("json.Unmarshal(response): %v", err)
}
return history.Records, nil
}
// RadarrQueue returns the Radarr Queue (processing, but not yet imported)
func (c *Config) RadarrQueue() ([]*RadarQueue, error) {
var queue []*RadarQueue
params := make(url.Values)
params.Set("sort_by", "timeleft")
params.Set("order", "asc")
rawJSON, err := c.Req("queue", params)
if err != nil {
return nil, fmt.Errorf("c.Req(queue): %v", err)
}
if err = json.Unmarshal(rawJSON, &queue); err != nil {
return nil, fmt.Errorf("json.Unmarshal(response): %v", err)
}
return queue, nil
}