Updated Polly

pull/470/head
tidusjar 9 years ago
parent 26e1d14812
commit 2c828ee54c

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

@ -35,6 +35,10 @@
<HintPath>..\packages\NLog.4.3.4\lib\net45\NLog.dll</HintPath> <HintPath>..\packages\NLog.4.3.4\lib\net45\NLog.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Polly, Version=4.3.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc, processorArchitecture=MSIL">
<HintPath>..\packages\Polly-Signed.4.3.0\lib\net45\Polly.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -59,9 +63,6 @@
<Reference Include="TMDbLib, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="TMDbLib, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\TMDbLib.0.9.0.0-alpha\lib\net45\TMDbLib.dll</HintPath> <HintPath>..\packages\TMDbLib.0.9.0.0-alpha\lib\net45\TMDbLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="Polly">
<HintPath>..\packages\Polly-Signed.4.2.0\lib\net45\Polly.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApiRequest.cs" /> <Compile Include="ApiRequest.cs" />

@ -4,7 +4,7 @@
<package id="Nancy" version="1.4.3" targetFramework="net45" /> <package id="Nancy" version="1.4.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net45" /> <package id="Newtonsoft.Json" version="8.0.2" targetFramework="net45" />
<package id="NLog" version="4.3.4" targetFramework="net45" /> <package id="NLog" version="4.3.4" targetFramework="net45" />
<package id="Polly-Signed" version="4.2.0" targetFramework="net45" /> <package id="Polly-Signed" version="4.3.0" targetFramework="net45" />
<package id="RestSharp" version="105.2.3" targetFramework="net45" /> <package id="RestSharp" version="105.2.3" targetFramework="net45" />
<package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net45" /> <package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net45" />
</packages> </packages>

@ -28,6 +28,10 @@
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Polly, Version=4.3.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc, processorArchitecture=MSIL">
<HintPath>..\packages\Polly-Signed.4.3.0\lib\net45\Polly.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" /> <Reference Include="System.IO.Compression.FileSystem" />

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Polly-Signed" version="4.2.0" targetFramework="net45" /> <package id="Polly-Signed" version="4.3.0" targetFramework="net45" />
</packages> </packages>
Loading…
Cancel
Save