Updated Polly

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

@ -49,8 +49,8 @@ namespace PlexRequests.Api
public bool AddMovie(string imdbid, string apiKey, string title, Uri baseUrl, string profileId = default(string)) public bool AddMovie(string imdbid, string apiKey, string title, Uri baseUrl, string profileId = default(string))
{ {
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,10 +125,10 @@ 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;
} }
public CouchPotatoMovies GetMovies(Uri baseUrl, string apiKey, string[] status) public CouchPotatoMovies GetMovies(Uri baseUrl, string apiKey, string[] status)
@ -147,21 +146,21 @@ 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();
} }
} }
} }

@ -1,124 +1,125 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8CB8D235-2674-442D-9C6A-35FCAEEB160D}</ProjectGuid> <ProjectGuid>{8CB8D235-2674-442D-9C6A-35FCAEEB160D}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PlexRequests.Api</RootNamespace> <RootNamespace>PlexRequests.Api</RootNamespace>
<AssemblyName>PlexRequests.Api</AssemblyName> <AssemblyName>PlexRequests.Api</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<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="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Polly, Version=4.3.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath> <HintPath>..\packages\Polly-Signed.4.3.0\lib\net45\Polly.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="System.Core" /> <HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath>
<Reference Include="System.Xml.Linq" /> <Private>True</Private>
<Reference Include="System.Data.DataSetExtensions" /> </Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Core" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Microsoft.CSharp" />
<HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath> <Reference Include="System.Data" />
</Reference> <Reference Include="System.Net.Http" />
<Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="System.Xml" />
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath> <Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, PublicKeyToken=null">
</Reference> <HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"> </Reference>
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> <Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, PublicKeyToken=null">
</Reference> <HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
<Reference Include="TMDbLib, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null"> </Reference>
<HintPath>..\packages\TMDbLib.0.9.0.0-alpha\lib\net45\TMDbLib.dll</HintPath> <Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
</Reference> <HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Polly"> </Reference>
<HintPath>..\packages\Polly-Signed.4.2.0\lib\net45\Polly.dll</HintPath> <Reference Include="TMDbLib, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null">
</Reference> <HintPath>..\packages\TMDbLib.0.9.0.0-alpha\lib\net45\TMDbLib.dll</HintPath>
</ItemGroup> </Reference>
<ItemGroup> </ItemGroup>
<Compile Include="ApiRequest.cs" /> <ItemGroup>
<Compile Include="MusicBrainzApi.cs" /> <Compile Include="ApiRequest.cs" />
<Compile Include="MockApiData.Designer.cs"> <Compile Include="MusicBrainzApi.cs" />
<AutoGen>True</AutoGen> <Compile Include="MockApiData.Designer.cs">
<DesignTime>True</DesignTime> <AutoGen>True</AutoGen>
<DependentUpon>MockApiData.resx</DependentUpon> <DesignTime>True</DesignTime>
</Compile> <DependentUpon>MockApiData.resx</DependentUpon>
<Compile Include="Mocks\MockSonarrApi.cs" /> </Compile>
<Compile Include="SlackApi.cs" /> <Compile Include="Mocks\MockSonarrApi.cs" />
<Compile Include="PushoverApi.cs" /> <Compile Include="SlackApi.cs" />
<Compile Include="PushbulletApi.cs" /> <Compile Include="PushoverApi.cs" />
<Compile Include="SickrageApi.cs" /> <Compile Include="PushbulletApi.cs" />
<Compile Include="HeadphonesApi.cs" /> <Compile Include="SickrageApi.cs" />
<Compile Include="SonarrApi.cs" /> <Compile Include="HeadphonesApi.cs" />
<Compile Include="CouchPotatoApi.cs" /> <Compile Include="SonarrApi.cs" />
<Compile Include="MovieBase.cs" /> <Compile Include="CouchPotatoApi.cs" />
<Compile Include="PlexApi.cs" /> <Compile Include="MovieBase.cs" />
<Compile Include="TheMovieDbApi.cs" /> <Compile Include="PlexApi.cs" />
<Compile Include="TvBase.cs" /> <Compile Include="TheMovieDbApi.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="TvBase.cs" />
<Compile Include="TheTvDbApi.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TvMazeApi.cs" /> <Compile Include="TheTvDbApi.cs" />
<Compile Include="TvMazeBase.cs" /> <Compile Include="TvMazeApi.cs" />
<Compile Include="RetryHandler.cs" /> <Compile Include="TvMazeBase.cs" />
</ItemGroup> <Compile Include="RetryHandler.cs" />
<ItemGroup> </ItemGroup>
<None Include="app.config" /> <ItemGroup>
<None Include="packages.config" /> <None Include="app.config" />
</ItemGroup> <None Include="packages.config" />
<ItemGroup> </ItemGroup>
<ProjectReference Include="..\PlexRequests.Api.Interfaces\PlexRequests.Api.Interfaces.csproj"> <ItemGroup>
<Project>{95834072-A675-415D-AA8F-877C91623810}</Project> <ProjectReference Include="..\PlexRequests.Api.Interfaces\PlexRequests.Api.Interfaces.csproj">
<Name>PlexRequests.Api.Interfaces</Name> <Project>{95834072-A675-415D-AA8F-877C91623810}</Project>
</ProjectReference> <Name>PlexRequests.Api.Interfaces</Name>
<ProjectReference Include="..\PlexRequests.Api.Models\PlexRequests.Api.Models.csproj"> </ProjectReference>
<Project>{CB37A5F8-6DFC-4554-99D3-A42B502E4591}</Project> <ProjectReference Include="..\PlexRequests.Api.Models\PlexRequests.Api.Models.csproj">
<Name>PlexRequests.Api.Models</Name> <Project>{CB37A5F8-6DFC-4554-99D3-A42B502E4591}</Project>
</ProjectReference> <Name>PlexRequests.Api.Models</Name>
<ProjectReference Include="..\PlexRequests.Helpers\PlexRequests.Helpers.csproj"> </ProjectReference>
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project> <ProjectReference Include="..\PlexRequests.Helpers\PlexRequests.Helpers.csproj">
<Name>PlexRequests.Helpers</Name> <Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
</ProjectReference> <Name>PlexRequests.Helpers</Name>
</ItemGroup> </ProjectReference>
<ItemGroup> </ItemGroup>
<EmbeddedResource Include="MockApiData.resx"> <ItemGroup>
<Generator>ResXFileCodeGenerator</Generator> <EmbeddedResource Include="MockApiData.resx">
<LastGenOutput>MockApiData.Designer.cs</LastGenOutput> <Generator>ResXFileCodeGenerator</Generator>
</EmbeddedResource> <LastGenOutput>MockApiData.Designer.cs</LastGenOutput>
</ItemGroup> </EmbeddedResource>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Other similar extension points exist, see Microsoft.Common.targets. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<Target Name="BeforeBuild"> Other similar extension points exist, see Microsoft.Common.targets.
</Target> <Target Name="BeforeBuild">
<Target Name="AfterBuild"> </Target>
</Target> <Target Name="AfterBuild">
--> </Target>
-->
</Project> </Project>

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup></configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup></configuration>

@ -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