|
|
|
@ -50,7 +50,7 @@ namespace PlexRequests.Api
|
|
|
|
|
{
|
|
|
|
|
RestRequest request;
|
|
|
|
|
request = string.IsNullOrEmpty(profileId)
|
|
|
|
|
? new RestRequest {Resource = "/api/{apikey}/movie.add?title={title}&identifier={imdbid}"}
|
|
|
|
|
? new RestRequest { Resource = "/api/{apikey}/movie.add?title={title}&identifier={imdbid}" }
|
|
|
|
|
: new RestRequest { Resource = "/api/{apikey}/movie.add?title={title}&identifier={imdbid}&profile_id={profileId}" };
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(profileId))
|
|
|
|
@ -62,11 +62,11 @@ namespace PlexRequests.Api
|
|
|
|
|
request.AddUrlSegment("imdbid", imdbid);
|
|
|
|
|
request.AddUrlSegment("title", title);
|
|
|
|
|
|
|
|
|
|
var obj = RetryHandler.Execute(() => Api.ExecuteJson<JObject> (request, baseUrl),new[] {
|
|
|
|
|
var obj = RetryHandler.Execute(() => Api.ExecuteJson<JObject>(request, baseUrl), new[] {
|
|
|
|
|
TimeSpan.FromSeconds (2),
|
|
|
|
|
TimeSpan.FromSeconds(5),
|
|
|
|
|
TimeSpan.FromSeconds(10)},
|
|
|
|
|
(exception, timespan) => Log.Error (exception, "Exception when calling AddMovie for CP, Retrying {0}", timespan));
|
|
|
|
|
(exception, timespan) => Log.Error(exception, "Exception when calling AddMovie for CP, Retrying {0}", timespan));
|
|
|
|
|
|
|
|
|
|
Log.Trace("CP movie Add result count {0}", obj.Count);
|
|
|
|
|
|
|
|
|
@ -106,18 +106,17 @@ namespace PlexRequests.Api
|
|
|
|
|
request.AddUrlSegment("apikey", apiKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var obj = RetryHandler.Execute<CouchPotatoStatus>(() => Api.Execute<CouchPotatoStatus> (request, url),new TimeSpan[] {
|
|
|
|
|
var obj = RetryHandler.Execute<CouchPotatoStatus>(() => Api.Execute<CouchPotatoStatus>(request, url), new TimeSpan[] {
|
|
|
|
|
TimeSpan.FromSeconds (2),
|
|
|
|
|
TimeSpan.FromSeconds(5),
|
|
|
|
|
TimeSpan.FromSeconds(10)},
|
|
|
|
|
(exception, timespan) => Log.Error (exception, "Exception when calling GetStatus for CP, Retrying {0}", timespan));
|
|
|
|
|
(exception, timespan) => Log.Error(exception, "Exception when calling GetStatus for CP, Retrying {0}", timespan));
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CouchPotatoProfiles GetProfiles(Uri url, string apiKey)
|
|
|
|
|
{
|
|
|
|
|
Log.Trace("Getting CP Profiles, ApiKey = {0}", apiKey);
|
|
|
|
|
var request = new RestRequest
|
|
|
|
|
{
|
|
|
|
|
Resource = "api/{apikey}/profile.list/",
|
|
|
|
@ -126,8 +125,8 @@ namespace PlexRequests.Api
|
|
|
|
|
|
|
|
|
|
request.AddUrlSegment("apikey", apiKey);
|
|
|
|
|
|
|
|
|
|
var obj = RetryHandler.Execute(() => Api.Execute<CouchPotatoProfiles> (request, url),null,
|
|
|
|
|
(exception, timespan) => Log.Error (exception, "Exception when calling GetProfiles for CP, Retrying {0}", timespan));
|
|
|
|
|
var obj = RetryHandler.Execute(() => Api.Execute<CouchPotatoProfiles>(request, url), null,
|
|
|
|
|
(exception, timespan) => Log.Error(exception, "Exception when calling GetProfiles for CP, Retrying {0}", timespan));
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
@ -147,20 +146,20 @@ namespace PlexRequests.Api
|
|
|
|
|
request.AddUrlSegment("status", string.Join(",", status));
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var obj = RetryHandler.Execute(() => Api.Execute<CouchPotatoMovies> (request, baseUrl),
|
|
|
|
|
var obj = RetryHandler.Execute(() => Api.Execute<CouchPotatoMovies>(request, baseUrl),
|
|
|
|
|
new[] {
|
|
|
|
|
TimeSpan.FromSeconds (5),
|
|
|
|
|
TimeSpan.FromSeconds(10),
|
|
|
|
|
TimeSpan.FromSeconds(30)
|
|
|
|
|
},
|
|
|
|
|
(exception, timespan) => Log.Error (exception, "Exception when calling GetMovies for CP, Retrying {0}", timespan));
|
|
|
|
|
(exception, timespan) => Log.Error(exception, "Exception when calling GetMovies for CP, Retrying {0}", timespan));
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) // Request error is already logged in the ApiRequest class
|
|
|
|
|
{
|
|
|
|
|
Log.Error("Error when attempting to GetMovies.");
|
|
|
|
|
Log.Error (e);
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
return new CouchPotatoMovies();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|