aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj112
-rw-r--r--MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs23
-rw-r--r--MediaBrowser.ApiInteraction.Portable/app.config27
-rw-r--r--MediaBrowser.ApiInteraction.Portable/packages.config8
-rw-r--r--MediaBrowser.ApiInteraction/ApiClient.cs1029
-rw-r--r--MediaBrowser.ApiInteraction/AsyncHttpClient.cs234
-rw-r--r--MediaBrowser.ApiInteraction/BaseApiClient.cs857
-rw-r--r--MediaBrowser.ApiInteraction/IAsyncHttpClient.cs49
-rw-r--r--MediaBrowser.ApiInteraction/MediaBrowser.ApiInteraction.csproj83
-rw-r--r--MediaBrowser.ApiInteraction/NewtonsoftJsonSerializer.cs141
-rw-r--r--MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs30
-rw-r--r--MediaBrowser.ApiInteraction/SerializationFormats.cs18
-rw-r--r--MediaBrowser.ApiInteraction/packages.config4
-rw-r--r--MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj56
-rw-r--r--MediaBrowser.Common.Implementations/swagger-ui/index.html2
-rw-r--r--MediaBrowser.ServerApplication/App.config9
-rw-r--r--MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj15
-rw-r--r--MediaBrowser.ServerApplication/packages.config2
-rw-r--r--MediaBrowser.sln34
-rw-r--r--Nuget/MediaBrowser.ApiClient.nuspec27
20 files changed, 50 insertions, 2710 deletions
diff --git a/MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj b/MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj
deleted file mode 100644
index 22b1a030e..000000000
--- a/MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<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')" />
- <PropertyGroup>
- <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{52E0C440-85C0-4A99-ACFE-07C87B2600BE}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>MediaBrowser.ApiInteraction.Portable</RootNamespace>
- <AssemblyName>MediaBrowser.ApiInteraction.Portable</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
- <FileAlignment>512</FileAlignment>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
- <RestorePackages>true</RestorePackages>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Compile Include="..\MediaBrowser.ApiInteraction\AsyncHttpClient.cs">
- <Link>AsyncHttpClient.cs</Link>
- </Compile>
- <Compile Include="..\MediaBrowser.ApiInteraction\NewtonsoftJsonSerializer.cs">
- <Link>NewtonsoftJsonSerializer.cs</Link>
- </Compile>
- <Compile Include="..\MediaBrowser.ApiInteraction\SerializationFormats.cs">
- <Link>SerializationFormats.cs</Link>
- </Compile>
- <Compile Include="..\SharedVersion.cs">
- <Link>Properties\SharedVersion.cs</Link>
- </Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="..\MediaBrowser.ApiInteraction\BaseApiClient.cs">
- <Link>BaseApiClient.cs</Link>
- </Compile>
- <Compile Include="..\MediaBrowser.ApiInteraction\ApiClient.cs">
- <Link>ApiClient.cs</Link>
- </Compile>
- <Compile Include="..\MediaBrowser.ApiInteraction\IAsyncHttpClient.cs">
- <Link>IAsyncHttpClient.cs</Link>
- </Compile>
- </ItemGroup>
- <ItemGroup>
- <Reference Include="Microsoft.Threading.Tasks">
- <HintPath>..\packages\Microsoft.Bcl.Async.1.0.14-rc\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Threading.Tasks.Extensions">
- <HintPath>..\packages\Microsoft.Bcl.Async.1.0.14-rc\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
- </Reference>
- <Reference Include="Newtonsoft.Json">
- <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
- </Reference>
- <Reference Include="System.Net.Http">
- <HintPath>..\packages\Microsoft.Net.Http.2.1.3-beta\lib\portable-net40+sl4+win8+wp71\System.Net.Http.dll</HintPath>
- </Reference>
- <Reference Include="System.Net.Http.Extensions">
- <HintPath>..\packages\Microsoft.Net.Http.2.1.3-beta\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Extensions.dll</HintPath>
- </Reference>
- <Reference Include="System.Net.Http.Primitives">
- <HintPath>..\packages\Microsoft.Net.Http.2.1.3-beta\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll</HintPath>
- </Reference>
- <Reference Include="System.Runtime">
- <HintPath>..\packages\Microsoft.Bcl.1.0.16-rc\lib\portable-net40+sl4+win8+wp71\System.Runtime.dll</HintPath>
- </Reference>
- <Reference Include="System.Threading.Tasks">
- <HintPath>..\packages\Microsoft.Bcl.1.0.16-rc\lib\portable-net40+sl4+win8+wp71\System.Threading.Tasks.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
- <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
- <Name>MediaBrowser.Model</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="app.config" />
- <None Include="packages.config" />
- </ItemGroup>
- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
- <Import Project="..\packages\Microsoft.Bcl.Build.1.0.0-rc\tools\Microsoft.Bcl.Build.targets" />
- <PropertyGroup>
- <PostBuildEvent>if $(ConfigurationName) == Release (
-xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i
-)</PostBuildEvent>
- </PropertyGroup>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
diff --git a/MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs b/MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs
deleted file mode 100644
index e14673826..000000000
--- a/MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System.Reflection;
-using System.Resources;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("MediaBrowser.ApiInteraction.Portable")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MediaBrowser.ApiInteraction.Portable")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: NeutralResourcesLanguage("en")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-// \ No newline at end of file
diff --git a/MediaBrowser.ApiInteraction.Portable/app.config b/MediaBrowser.ApiInteraction.Portable/app.config
deleted file mode 100644
index f356f9b87..000000000
--- a/MediaBrowser.ApiInteraction.Portable/app.config
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <runtime>
- <assemblyBinding xmlns:bcl="urn:schemas-microsoft-com:bcl" xmlns="urn:schemas-microsoft-com:asm.v1">
- <dependentAssembly bcl:name="System.Runtime">
- <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-1.5.11.0" newVersion="1.5.11.0" />
- </dependentAssembly>
- <dependentAssembly bcl:name="System.Threading.Tasks">
- <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-1.5.11.0" newVersion="1.5.11.0" />
- </dependentAssembly>
- <dependentAssembly bcl:name="System.Net.Http">
- <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
- </dependentAssembly>
- <dependentAssembly bcl:name="System.Net.Http.Primitives">
- <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
- </dependentAssembly>
- <dependentAssembly bcl:name="System.Net.Http.Extensions">
- <assemblyIdentity name="System.Net.Http.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
- </dependentAssembly>
- </assemblyBinding>
- </runtime>
-</configuration> \ No newline at end of file
diff --git a/MediaBrowser.ApiInteraction.Portable/packages.config b/MediaBrowser.ApiInteraction.Portable/packages.config
deleted file mode 100644
index 795bf139c..000000000
--- a/MediaBrowser.ApiInteraction.Portable/packages.config
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Microsoft.Bcl" version="1.0.16-rc" targetFramework="portable-win+net45+sl40+wp71" />
- <package id="Microsoft.Bcl.Async" version="1.0.14-rc" targetFramework="portable-win+net45+sl40+wp71" />
- <package id="Microsoft.Bcl.Build" version="1.0.0-rc" targetFramework="portable-win+net45+sl40+wp71" />
- <package id="Microsoft.Net.Http" version="2.1.3-beta" targetFramework="portable-win+net45+sl40+wp71" />
- <package id="Newtonsoft.Json" version="4.5.11" targetFramework="portable-win+net45+sl40+wp71" />
-</packages> \ No newline at end of file
diff --git a/MediaBrowser.ApiInteraction/ApiClient.cs b/MediaBrowser.ApiInteraction/ApiClient.cs
deleted file mode 100644
index 5268c7e1f..000000000
--- a/MediaBrowser.ApiInteraction/ApiClient.cs
+++ /dev/null
@@ -1,1029 +0,0 @@
-using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Globalization;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Plugins;
-using MediaBrowser.Model.System;
-using MediaBrowser.Model.Tasks;
-using MediaBrowser.Model.Weather;
-using MediaBrowser.Model.Web;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.ApiInteraction
-{
- /// <summary>
- /// Provides api methods centered around an HttpClient
- /// </summary>
- public class ApiClient : BaseApiClient
- {
- /// <summary>
- /// Gets the HTTP client.
- /// </summary>
- /// <value>The HTTP client.</value>
- protected IAsyncHttpClient HttpClient { get; private set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ApiClient" /> class.
- /// </summary>
- /// <param name="logger">The logger.</param>
- /// <param name="httpClient">The HTTP client.</param>
- /// <exception cref="System.ArgumentNullException">httpClient</exception>
- public ApiClient(ILogger logger, IAsyncHttpClient httpClient)
- : base(logger)
- {
- if (httpClient == null)
- {
- throw new ArgumentNullException("httpClient");
- }
-
- HttpClient = httpClient;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ApiClient" /> class.
- /// </summary>
- /// <param name="logger">The logger.</param>
- public ApiClient(ILogger logger)
- : this(logger, new AsyncHttpClient())
- {
- }
-
- /// <summary>
- /// Sets the authorization header.
- /// </summary>
- /// <param name="header">The header.</param>
- protected override void SetAuthorizationHeader(string header)
- {
- HttpClient.SetAuthorizationHeader(header);
- }
-
- /// <summary>
- /// Gets an image stream based on a url
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <returns>Task{Stream}.</returns>
- /// <exception cref="System.ArgumentNullException">url</exception>
- public Task<Stream> GetImageStreamAsync(string url)
- {
- if (string.IsNullOrEmpty(url))
- {
- throw new ArgumentNullException("url");
- }
-
- return HttpClient.GetAsync(url, Logger, CancellationToken.None);
- }
-
- /// <summary>
- /// Gets a BaseItem
- /// </summary>
- /// <param name="id">The id.</param>
- /// <param name="userId">The user id.</param>
- /// <returns>Task{BaseItemDto}.</returns>
- /// <exception cref="System.ArgumentNullException">id</exception>
- public async Task<BaseItemDto> GetItemAsync(string id, Guid userId)
- {
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException("id");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + id);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto>(stream);
- }
- }
-
- /// <summary>
- /// Gets the intros async.
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <returns>Task{System.String[]}.</returns>
- /// <exception cref="System.ArgumentNullException">id</exception>
- public async Task<string[]> GetIntrosAsync(string itemId, Guid userId)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + itemId + "/Intros");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<string[]>(stream);
- }
- }
-
- /// <summary>
- /// Gets a BaseItem
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <returns>Task{BaseItemDto}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<BaseItemDto> GetRootFolderAsync(Guid userId)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/Root");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto>(stream);
- }
- }
-
- /// <summary>
- /// Gets all Users
- /// </summary>
- /// <returns>Task{UserDto[]}.</returns>
- public async Task<UserDto[]> GetAllUsersAsync()
- {
- var url = GetApiUrl("Users");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<UserDto[]>(stream);
- }
- }
-
- /// <summary>
- /// Queries for items
- /// </summary>
- /// <param name="query">The query.</param>
- /// <returns>Task{ItemsResult}.</returns>
- /// <exception cref="System.ArgumentNullException">query</exception>
- public async Task<ItemsResult> GetItemsAsync(ItemQuery query)
- {
- if (query == null)
- {
- throw new ArgumentNullException("query");
- }
-
- var url = GetItemListUrl(query);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<ItemsResult>(stream);
- }
- }
-
- /// <summary>
- /// Gets all People
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <param name="itemId">Optional itemId, to localize the search to a specific item or folder</param>
- /// <param name="personTypes">Use this to limit results to specific person types</param>
- /// <param name="startIndex">Used to skip over a given number of items. Use if paging.</param>
- /// <param name="limit">The maximum number of items to return</param>
- /// <param name="sortOrder">The sort order</param>
- /// <param name="recursive">if set to true items will be searched recursively.</param>
- /// <returns>Task{IbnItemsResult}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<ItemsResult> GetAllPeopleAsync(
- Guid userId,
- string itemId = null,
- IEnumerable<string> personTypes = null,
- int? startIndex = null,
- int? limit = null,
- SortOrder? sortOrder = null,
- bool recursive = false)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var dict = new QueryStringDictionary();
-
- dict.AddIfNotNull("startIndex", startIndex);
- dict.AddIfNotNull("limit", limit);
-
- dict.Add("recursive", recursive);
-
- if (sortOrder.HasValue)
- {
- dict["sortOrder"] = sortOrder.Value.ToString();
- }
-
- dict.AddIfNotNull("personTypes", personTypes);
-
- var url = string.IsNullOrEmpty(itemId) ? "Users/" + userId + "/Items/Root/Persons" : "Users/" + userId + "/Items/" + itemId + "/Persons";
- url = GetApiUrl(url, dict);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<ItemsResult>(stream);
- }
- }
-
- /// <summary>
- /// Gets a studio
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns>Task{BaseItemDto}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<BaseItemDto> GetStudioAsync(string name)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException("name");
- }
-
- var url = GetApiUrl("Library/Studios/" + name);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto>(stream);
- }
- }
-
- /// <summary>
- /// Gets a genre
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns>Task{BaseItemDto}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<BaseItemDto> GetGenreAsync(string name)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException("name");
- }
-
- var url = GetApiUrl("Library/Genres/" + name);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto>(stream);
- }
- }
-
- /// <summary>
- /// Restarts the kernel or the entire server if necessary
- /// If the server application is restarting this request will fail to return, even if
- /// the operation is successful.
- /// </summary>
- /// <returns>Task.</returns>
- public Task PerformPendingRestartAsync()
- {
- var url = GetApiUrl("System/Restart");
-
- return PostAsync<EmptyRequestResult>(url, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the system status async.
- /// </summary>
- /// <returns>Task{SystemInfo}.</returns>
- public async Task<SystemInfo> GetSystemInfoAsync()
- {
- var url = GetApiUrl("System/Info");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<SystemInfo>(stream);
- }
- }
-
- /// <summary>
- /// Gets a person
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns>Task{BaseItemDto}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<BaseItemDto> GetPersonAsync(string name)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException("name");
- }
-
- var url = GetApiUrl("Library/Persons/" + name);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto>(stream);
- }
- }
-
- /// <summary>
- /// Gets a year
- /// </summary>
- /// <param name="year">The year.</param>
- /// <returns>Task{BaseItemDto}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<BaseItemDto> GetYearAsync(int year)
- {
- var url = GetApiUrl("Library/Years/" + year);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto>(stream);
- }
- }
-
- /// <summary>
- /// Gets a list of plugins installed on the server
- /// </summary>
- /// <returns>Task{PluginInfo[]}.</returns>
- public async Task<PluginInfo[]> GetInstalledPluginsAsync()
- {
- var url = GetApiUrl("Plugins");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<PluginInfo[]>(stream);
- }
- }
-
- /// <summary>
- /// Gets a list of plugins installed on the server
- /// </summary>
- /// <param name="plugin">The plugin.</param>
- /// <returns>Task{Stream}.</returns>
- /// <exception cref="System.ArgumentNullException">plugin</exception>
- public Task<Stream> GetPluginAssemblyAsync(PluginInfo plugin)
- {
- if (plugin == null)
- {
- throw new ArgumentNullException("plugin");
- }
-
- var url = GetApiUrl("Plugins/" + plugin.Id + "/Assembly");
-
- return HttpClient.GetAsync(url, Logger, CancellationToken.None);
- }
-
- /// <summary>
- /// Gets the current server configuration
- /// </summary>
- /// <returns>Task{ServerConfiguration}.</returns>
- public async Task<ServerConfiguration> GetServerConfigurationAsync()
- {
- var url = GetApiUrl("System/Configuration");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<ServerConfiguration>(stream);
- }
- }
-
- /// <summary>
- /// Gets the scheduled tasks.
- /// </summary>
- /// <returns>Task{TaskInfo[]}.</returns>
- public async Task<TaskInfo[]> GetScheduledTasksAsync()
- {
- var url = GetApiUrl("ScheduledTasks");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<TaskInfo[]>(stream);
- }
- }
-
- /// <summary>
- /// Gets the scheduled task async.
- /// </summary>
- /// <param name="id">The id.</param>
- /// <returns>Task{TaskInfo}.</returns>
- /// <exception cref="System.ArgumentNullException">id</exception>
- public async Task<TaskInfo> GetScheduledTaskAsync(Guid id)
- {
- if (id == Guid.Empty)
- {
- throw new ArgumentNullException("id");
- }
-
- var url = GetApiUrl("ScheduledTasks/" + id);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<TaskInfo>(stream);
- }
- }
-
- /// <summary>
- /// Gets the plugin configuration file in plain text.
- /// </summary>
- /// <param name="pluginId">The plugin id.</param>
- /// <returns>Task{Stream}.</returns>
- /// <exception cref="System.ArgumentNullException">assemblyFileName</exception>
- public async Task<Stream> GetPluginConfigurationFileAsync(Guid pluginId)
- {
- if (pluginId == Guid.Empty)
- {
- throw new ArgumentNullException("pluginId");
- }
-
- var url = GetApiUrl("Plugins/" + pluginId + "/ConfigurationFile");
-
- return await HttpClient.GetAsync(url, Logger, CancellationToken.None).ConfigureAwait(false);
- }
-
- /// <summary>
- /// Gets a user by id
- /// </summary>
- /// <param name="id">The id.</param>
- /// <returns>Task{UserDto}.</returns>
- /// <exception cref="System.ArgumentNullException">id</exception>
- public async Task<UserDto> GetUserAsync(Guid id)
- {
- if (id == Guid.Empty)
- {
- throw new ArgumentNullException("id");
- }
-
- var url = GetApiUrl("Users/" + id);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<UserDto>(stream);
- }
- }
-
- /// <summary>
- /// Gets the parental ratings async.
- /// </summary>
- /// <returns>Task{List{ParentalRating}}.</returns>
- public async Task<List<ParentalRating>> GetParentalRatingsAsync()
- {
- var url = GetApiUrl("Localization/ParentalRatings");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<List<ParentalRating>>(stream);
- }
- }
-
- /// <summary>
- /// Gets weather information for the default location as set in configuration
- /// </summary>
- /// <returns>Task{WeatherInfo}.</returns>
- public async Task<WeatherInfo> GetWeatherInfoAsync()
- {
- var url = GetApiUrl("Weather");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<WeatherInfo>(stream);
- }
- }
-
- /// <summary>
- /// Gets weather information for a specific location
- /// Location can be a US zipcode, or "city,state", "city,state,country", "city,country"
- /// It can also be an ip address, or "latitude,longitude"
- /// </summary>
- /// <param name="location">The location.</param>
- /// <returns>Task{WeatherInfo}.</returns>
- /// <exception cref="System.ArgumentNullException">location</exception>
- public async Task<WeatherInfo> GetWeatherInfoAsync(string location)
- {
- if (string.IsNullOrEmpty(location))
- {
- throw new ArgumentNullException("location");
- }
-
- var dict = new QueryStringDictionary();
-
- dict.Add("location", location);
-
- var url = GetApiUrl("Weather", dict);
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<WeatherInfo>(stream);
- }
- }
-
- /// <summary>
- /// Gets local trailers for an item
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <param name="itemId">The item id.</param>
- /// <returns>Task{ItemsResult}.</returns>
- /// <exception cref="System.ArgumentNullException">query</exception>
- public async Task<BaseItemDto[]> GetLocalTrailersAsync(Guid userId, string itemId)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + itemId + "/LocalTrailers");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto[]>(stream);
- }
- }
-
- /// <summary>
- /// Gets special features for an item
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <param name="itemId">The item id.</param>
- /// <returns>Task{BaseItemDto[]}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public async Task<BaseItemDto[]> GetSpecialFeaturesAsync(Guid userId, string itemId)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + itemId + "/SpecialFeatures");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<BaseItemDto[]>(stream);
- }
- }
-
- /// <summary>
- /// Gets the cultures async.
- /// </summary>
- /// <returns>Task{CultureDto[]}.</returns>
- public async Task<CultureDto[]> GetCulturesAsync()
- {
- var url = GetApiUrl("Localization/Cultures");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<CultureDto[]>(stream);
- }
- }
-
- /// <summary>
- /// Gets the countries async.
- /// </summary>
- /// <returns>Task{CountryInfo[]}.</returns>
- public async Task<CountryInfo[]> GetCountriesAsync()
- {
- var url = GetApiUrl("Localization/Countries");
-
- using (var stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
- {
- return DeserializeFromStream<CountryInfo[]>(stream);
- }
- }
-
- /// <summary>
- /// Marks an item as played or unplayed.
- /// This should not be used to update playstate following playback.
- /// There are separate playstate check-in methods for that. This should be used for a
- /// separate option to reset playstate.
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <param name="wasPlayed">if set to <c>true</c> [was played].</param>
- /// <returns>Task.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task UpdatePlayedStatusAsync(string itemId, Guid userId, bool wasPlayed)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/PlayedItems/" + itemId);
-
- if (wasPlayed)
- {
- return PostAsync<EmptyRequestResult>(url, new Dictionary<string, string>());
- }
-
- return HttpClient.DeleteAsync(url, Logger, CancellationToken.None);
- }
-
- /// <summary>
- /// Updates the favorite status async.
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <param name="isFavorite">if set to <c>true</c> [is favorite].</param>
- /// <returns>Task.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task UpdateFavoriteStatusAsync(string itemId, Guid userId, bool isFavorite)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/FavoriteItems/" + itemId);
-
- if (isFavorite)
- {
- return PostAsync<EmptyRequestResult>(url, new Dictionary<string, string>());
- }
-
- return HttpClient.DeleteAsync(url, Logger, CancellationToken.None);
- }
-
- /// <summary>
- /// Reports to the server that the user has begun playing an item
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <returns>Task{UserItemDataDto}.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task ReportPlaybackStartAsync(string itemId, Guid userId)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/PlayingItems/" + itemId);
-
- return PostAsync<EmptyRequestResult>(url, new Dictionary<string, string>());
- }
-
- /// <summary>
- /// Reports playback progress to the server
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <param name="positionTicks">The position ticks.</param>
- /// <returns>Task{UserItemDataDto}.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task ReportPlaybackProgressAsync(string itemId, Guid userId, long? positionTicks)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var dict = new QueryStringDictionary();
- dict.AddIfNotNull("positionTicks", positionTicks);
-
- var url = GetApiUrl("Users/" + userId + "/PlayingItems/" + itemId + "/Progress", dict);
-
- return PostAsync<EmptyRequestResult>(url, new Dictionary<string, string>());
- }
-
- /// <summary>
- /// Reports to the server that the user has stopped playing an item
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <param name="positionTicks">The position ticks.</param>
- /// <returns>Task{UserItemDataDto}.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task ReportPlaybackStoppedAsync(string itemId, Guid userId, long? positionTicks)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var dict = new QueryStringDictionary();
- dict.AddIfNotNull("positionTicks", positionTicks);
-
- var url = GetApiUrl("Users/" + userId + "/PlayingItems/" + itemId, dict);
-
- return HttpClient.DeleteAsync(url, Logger, CancellationToken.None);
- }
-
- /// <summary>
- /// Clears a user's rating for an item
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <returns>Task{UserItemDataDto}.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task ClearUserItemRatingAsync(string itemId, Guid userId)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + itemId + "/Rating");
-
- return HttpClient.DeleteAsync(url, Logger, CancellationToken.None);
- }
-
- /// <summary>
- /// Updates a user's rating for an item, based on likes or dislikes
- /// </summary>
- /// <param name="itemId">The item id.</param>
- /// <param name="userId">The user id.</param>
- /// <param name="likes">if set to <c>true</c> [likes].</param>
- /// <returns>Task{UserItemDataDto}.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public Task<UserItemDataDto> UpdateUserItemRatingAsync(string itemId, Guid userId, bool likes)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var dict = new QueryStringDictionary { };
-
- dict.Add("likes", likes);
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + itemId + "/Rating", dict);
-
- return PostAsync<UserItemDataDto>(url, new Dictionary<string, string>());
- }
-
- /// <summary>
- /// Authenticates a user and returns the result
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <param name="password">The password.</param>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public Task AuthenticateUserAsync(Guid userId, string password)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Authenticate");
-
- var args = new Dictionary<string, string>();
-
- if (!string.IsNullOrEmpty(password))
- {
- args["password"] = password;
- }
-
- return PostAsync<EmptyRequestResult>(url, args);
- }
-
- /// <summary>
- /// Uploads the user image async.
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <param name="imageType">Type of the image.</param>
- /// <param name="image">The image.</param>
- /// <returns>Task{RequestResult}.</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- public Task UploadUserImageAsync(Guid userId, ImageType imageType, Stream image)
- {
- // Implement when needed
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Updates the server configuration async.
- /// </summary>
- /// <param name="configuration">The configuration.</param>
- /// <returns>Task.</returns>
- /// <exception cref="System.ArgumentNullException">configuration</exception>
- public Task UpdateServerConfigurationAsync(ServerConfiguration configuration)
- {
- if (configuration == null)
- {
- throw new ArgumentNullException("configuration");
- }
-
- var url = GetApiUrl("System/Configuration");
-
- return PostAsync<ServerConfiguration, EmptyRequestResult>(url, configuration);
- }
-
- /// <summary>
- /// Updates the scheduled task triggers.
- /// </summary>
- /// <param name="id">The id.</param>
- /// <param name="triggers">The triggers.</param>
- /// <returns>Task{RequestResult}.</returns>
- /// <exception cref="System.ArgumentNullException">id</exception>
- public Task UpdateScheduledTaskTriggersAsync(Guid id, TaskTriggerInfo[] triggers)
- {
- if (id == Guid.Empty)
- {
- throw new ArgumentNullException("id");
- }
-
- if (triggers == null)
- {
- throw new ArgumentNullException("triggers");
- }
-
- var url = GetApiUrl("ScheduledTasks/" + id + "/Triggers");
-
- return PostAsync<TaskTriggerInfo[], EmptyRequestResult>(url, triggers);
- }
-
- /// <summary>
- /// Updates display preferences for a user
- /// </summary>
- /// <param name="userId">The user id.</param>
- /// <param name="itemId">The item id.</param>
- /// <param name="displayPreferences">The display preferences.</param>
- /// <returns>Task{DisplayPreferences}.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public Task UpdateDisplayPreferencesAsync(Guid userId, string itemId, DisplayPreferences displayPreferences)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- if (displayPreferences == null)
- {
- throw new ArgumentNullException("displayPreferences");
- }
-
- var url = GetApiUrl("Users/" + userId + "/Items/" + itemId + "/DisplayPreferences");
-
- return PostAsync<DisplayPreferences, EmptyRequestResult>(url, displayPreferences);
- }
-
- /// <summary>
- /// Posts a set of data to a url, and deserializes the return stream into T
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="url">The URL.</param>
- /// <param name="args">The args.</param>
- /// <returns>Task{``0}.</returns>
- private Task<T> PostAsync<T>(string url, Dictionary<string, string> args)
- where T : class
- {
- return PostAsync<T>(url, args, SerializationFormat);
- }
-
- /// <summary>
- /// Posts a set of data to a url, and deserializes the return stream into T
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="url">The URL.</param>
- /// <param name="args">The args.</param>
- /// <param name="serializationFormat">The serialization format.</param>
- /// <returns>Task{``0}.</returns>
- private async Task<T> PostAsync<T>(string url, Dictionary<string, string> args, SerializationFormats serializationFormat)
- where T : class
- {
- url = AddDataFormat(url, serializationFormat);
-
- // Create the post body
- var strings = args.Keys.Select(key => string.Format("{0}={1}", key, args[key]));
- var postContent = string.Join("&", strings.ToArray());
-
- const string contentType = "application/x-www-form-urlencoded";
-
- using (var stream = await HttpClient.PostAsync(url, contentType, postContent, Logger, CancellationToken.None).ConfigureAwait(false))
- {
- return DeserializeFromStream<T>(stream);
- }
- }
-
- /// <summary>
- /// Posts an object of type TInputType to a given url, and deserializes the response into an object of type TOutputType
- /// </summary>
- /// <typeparam name="TInputType">The type of the T input type.</typeparam>
- /// <typeparam name="TOutputType">The type of the T output type.</typeparam>
- /// <param name="url">The URL.</param>
- /// <param name="obj">The obj.</param>
- /// <returns>Task{``1}.</returns>
- private Task<TOutputType> PostAsync<TInputType, TOutputType>(string url, TInputType obj)
- where TOutputType : class
- {
- return PostAsync<TInputType, TOutputType>(url, obj, SerializationFormat);
- }
-
- /// <summary>
- /// Posts an object of type TInputType to a given url, and deserializes the response into an object of type TOutputType
- /// </summary>
- /// <typeparam name="TInputType">The type of the T input type.</typeparam>
- /// <typeparam name="TOutputType">The type of the T output type.</typeparam>
- /// <param name="url">The URL.</param>
- /// <param name="obj">The obj.</param>
- /// <param name="serializationFormat">The serialization format.</param>
- /// <returns>Task{``1}.</returns>
- private async Task<TOutputType> PostAsync<TInputType, TOutputType>(string url, TInputType obj, SerializationFormats serializationFormat)
- where TOutputType : class
- {
- url = AddDataFormat(url, serializationFormat);
-
- const string contentType = "application/x-www-form-urlencoded";
-
- var postContent = SerializeToJson(obj);
-
- using (var stream = await HttpClient.PostAsync(url, contentType, postContent, Logger, CancellationToken.None).ConfigureAwait(false))
- {
- return DeserializeFromStream<TOutputType>(stream);
- }
- }
-
- /// <summary>
- /// This is a helper around getting a stream from the server that contains serialized data
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <returns>Task{Stream}.</returns>
- public Task<Stream> GetSerializedStreamAsync(string url)
- {
- return GetSerializedStreamAsync(url, SerializationFormat);
- }
-
- /// <summary>
- /// This is a helper around getting a stream from the server that contains serialized data
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="serializationFormat">The serialization format.</param>
- /// <returns>Task{Stream}.</returns>
- public Task<Stream> GetSerializedStreamAsync(string url, SerializationFormats serializationFormat)
- {
- url = AddDataFormat(url, serializationFormat);
-
- return HttpClient.GetAsync(url, Logger, CancellationToken.None);
- }
-
-
- /// <summary>
- /// Adds the data format.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="serializationFormat">The serialization format.</param>
- /// <returns>System.String.</returns>
- private string AddDataFormat(string url, SerializationFormats serializationFormat)
- {
- var format = serializationFormat == SerializationFormats.Protobuf ? "x-protobuf" : serializationFormat.ToString();
-
- if (url.IndexOf('?') == -1)
- {
- url += "?format=" + format;
- }
- else
- {
- url += "&format=" + format;
- }
-
- return url;
- }
- }
-}
diff --git a/MediaBrowser.ApiInteraction/AsyncHttpClient.cs b/MediaBrowser.ApiInteraction/AsyncHttpClient.cs
deleted file mode 100644
index c6701cac0..000000000
--- a/MediaBrowser.ApiInteraction/AsyncHttpClient.cs
+++ /dev/null
@@ -1,234 +0,0 @@
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Net;
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.ApiInteraction
-{
- /// <summary>
- /// Class AsyncHttpClient
- /// </summary>
- public class AsyncHttpClient : IAsyncHttpClient
- {
- /// <summary>
- /// Gets or sets the HTTP client.
- /// </summary>
- /// <value>The HTTP client.</value>
- private HttpClient HttpClient { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ApiClient" /> class.
- /// </summary>
- public AsyncHttpClient(HttpMessageHandler handler)
- {
- HttpClient = new HttpClient(handler);
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ApiClient" /> class.
- /// </summary>
- public AsyncHttpClient()
- {
- HttpClient = new HttpClient();
- }
-
- /// <summary>
- /// Gets the stream async.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{Stream}.</returns>
- /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
- public async Task<Stream> GetAsync(string url, ILogger logger, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- logger.Debug("Sending Http Get to {0}", url);
-
- try
- {
- var msg = await HttpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
-
- EnsureSuccessStatusCode(msg);
-
- return await msg.Content.ReadAsStreamAsync().ConfigureAwait(false);
- }
- catch (HttpRequestException ex)
- {
- logger.ErrorException("Error getting response from " + url, ex);
-
- throw new HttpException(ex.Message, ex);
- }
- catch (OperationCanceledException ex)
- {
- throw GetCancellationException(url, cancellationToken, ex, logger);
- }
- catch (Exception ex)
- {
- logger.ErrorException("Error requesting {0}", ex, url);
-
- throw;
- }
- }
-
- /// <summary>
- /// Posts the async.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="contentType">Type of the content.</param>
- /// <param name="postContent">Content of the post.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{Stream}.</returns>
- /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
- public async Task<Stream> PostAsync(string url, string contentType, string postContent, ILogger logger, CancellationToken cancellationToken)
- {
- logger.Debug("Sending Http Post to {0}", url);
-
- var content = new StringContent(postContent, Encoding.UTF8, contentType);
-
- try
- {
- var msg = await HttpClient.PostAsync(url, content).ConfigureAwait(false);
-
- EnsureSuccessStatusCode(msg);
-
- return await msg.Content.ReadAsStreamAsync().ConfigureAwait(false);
- }
- catch (HttpRequestException ex)
- {
- logger.ErrorException("Error getting response from " + url, ex);
-
- throw new HttpException(ex.Message, ex);
- }
- catch (OperationCanceledException ex)
- {
- throw GetCancellationException(url, cancellationToken, ex, logger);
- }
- catch (Exception ex)
- {
- logger.ErrorException("Error posting {0}", ex, url);
-
- throw;
- }
- }
-
- /// <summary>
- /// Deletes the async.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task.</returns>
- public async Task DeleteAsync(string url, ILogger logger, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- logger.Debug("Sending Http Delete to {0}", url);
-
- try
- {
- using (var msg = await HttpClient.DeleteAsync(url, cancellationToken).ConfigureAwait(false))
- {
- EnsureSuccessStatusCode(msg);
- }
- }
- catch (HttpRequestException ex)
- {
- logger.ErrorException("Error getting response from " + url, ex);
-
- throw new HttpException(ex.Message, ex);
- }
- catch (OperationCanceledException ex)
- {
- throw GetCancellationException(url, cancellationToken, ex, logger);
- }
- catch (Exception ex)
- {
- logger.ErrorException("Error requesting {0}", ex, url);
-
- throw;
- }
- }
-
- /// <summary>
- /// Throws the cancellation exception.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <param name="exception">The exception.</param>
- /// <param name="logger">The logger.</param>
- /// <returns>Exception.</returns>
- private Exception GetCancellationException(string url, CancellationToken cancellationToken, OperationCanceledException exception, ILogger logger)
- {
- // If the HttpClient's timeout is reached, it will cancel the Task internally
- if (!cancellationToken.IsCancellationRequested)
- {
- var msg = string.Format("Connection to {0} timed out", url);
-
- logger.Error(msg);
-
- // Throw an HttpException so that the caller doesn't think it was cancelled by user code
- return new HttpException(msg, exception) { IsTimedOut = true };
- }
-
- return exception;
- }
-
- /// <summary>
- /// Ensures the success status code.
- /// </summary>
- /// <param name="response">The response.</param>
- /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
- private void EnsureSuccessStatusCode(HttpResponseMessage response)
- {
- if (!response.IsSuccessStatusCode)
- {
- throw new HttpException(response.ReasonPhrase) { StatusCode = response.StatusCode };
- }
- }
-
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- public void Dispose()
- {
- Dispose(true);
- }
-
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- HttpClient.Dispose();
- }
- }
-
- /// <summary>
- /// Sets the authorization header that should be supplied on every request
- /// </summary>
- /// <param name="header">The header.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- public void SetAuthorizationHeader(string header)
- {
- if (string.IsNullOrEmpty(header))
- {
- HttpClient.DefaultRequestHeaders.Remove("Authorization");
- }
- else
- {
- HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("MediaBrowser", header);
- }
- }
- }
-}
diff --git a/MediaBrowser.ApiInteraction/BaseApiClient.cs b/MediaBrowser.ApiInteraction/BaseApiClient.cs
deleted file mode 100644
index 6d5a5e7cb..000000000
--- a/MediaBrowser.ApiInteraction/BaseApiClient.cs
+++ /dev/null
@@ -1,857 +0,0 @@
-using MediaBrowser.Model.Connectivity;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Serialization;
-using MediaBrowser.Model.Web;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace MediaBrowser.ApiInteraction
-{
- /// <summary>
- /// Provides api methods that are usable on all platforms
- /// </summary>
- public abstract class BaseApiClient : IDisposable
- {
- /// <summary>
- /// Gets the logger.
- /// </summary>
- /// <value>The logger.</value>
- protected ILogger Logger { get; private set; }
-
- /// <summary>
- /// Gets the protobuf serializer.
- /// </summary>
- /// <value>The protobuf serializer.</value>
- public IProtobufSerializer ProtobufSerializer { get; set; }
-
- /// <summary>
- /// Gets the json serializer.
- /// </summary>
- /// <value>The json serializer.</value>
- public IJsonSerializer JsonSerializer { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BaseApiClient" /> class.
- /// </summary>
- /// <param name="logger">The logger.</param>
- /// <param name="jsonSerializer">The json serializer.</param>
- /// <exception cref="System.ArgumentNullException">logger</exception>
- protected BaseApiClient(ILogger logger)
- {
- if (logger == null)
- {
- throw new ArgumentNullException("logger");
- }
-
- JsonSerializer = new NewtonsoftJsonSerializer();
- Logger = logger;
- SerializationFormat = SerializationFormats.Json;
- }
-
- /// <summary>
- /// Gets or sets the server host name (myserver or 192.168.x.x)
- /// </summary>
- /// <value>The name of the server host.</value>
- public string ServerHostName { get; set; }
-
- /// <summary>
- /// Gets or sets the port number used by the API
- /// </summary>
- /// <value>The server API port.</value>
- public int ServerApiPort { get; set; }
-
- /// <summary>
- /// Gets or sets the type of the client.
- /// </summary>
- /// <value>The type of the client.</value>
- public ClientType ClientType { get; set; }
-
- /// <summary>
- /// Gets or sets the name of the device.
- /// </summary>
- /// <value>The name of the device.</value>
- public string DeviceName { get; set; }
-
- private Guid? _currentUserId;
-
- /// <summary>
- /// Gets or sets the current user id.
- /// </summary>
- /// <value>The current user id.</value>
- public virtual Guid? CurrentUserId
- {
- get { return _currentUserId; }
- set
- {
- _currentUserId = value;
- ResetAuthorizationHeader();
- }
- }
-
- /// <summary>
- /// Gets the current api url based on hostname and port.
- /// </summary>
- /// <value>The API URL.</value>
- protected string ApiUrl
- {
- get
- {
- return string.Format("http://{0}:{1}/mediabrowser", ServerHostName, ServerApiPort);
- }
- }
-
- /// <summary>
- /// Gets the default data format to request from the server
- /// </summary>
- /// <value>The serialization format.</value>
- public SerializationFormats SerializationFormat { get; set; }
-
- /// <summary>
- /// Resets the authorization header.
- /// </summary>
- private void ResetAuthorizationHeader()
- {
- if (!CurrentUserId.HasValue)
- {
- SetAuthorizationHeader(null);
- return;
- }
-
- var header = string.Format("UserId=\"{0}\", Client=\"{1}\"", CurrentUserId.Value, ClientType);
-
- if (!string.IsNullOrEmpty(DeviceName))
- {
- header += string.Format(", Device=\"{0}\"", DeviceName);
- }
-
- SetAuthorizationHeader(header);
- }
-
- /// <summary>
- /// Sets the authorization header.
- /// </summary>
- /// <param name="header">The header.</param>
- protected abstract void SetAuthorizationHeader(string header);
-
- /// <summary>
- /// Gets the API URL.
- /// </summary>
- /// <param name="handler">The handler.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">handler</exception>
- protected string GetApiUrl(string handler)
- {
- return GetApiUrl(handler, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the API URL.
- /// </summary>
- /// <param name="handler">The handler.</param>
- /// <param name="queryString">The query string.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">handler</exception>
- protected string GetApiUrl(string handler, QueryStringDictionary queryString)
- {
- if (string.IsNullOrEmpty(handler))
- {
- throw new ArgumentNullException("handler");
- }
-
- if (queryString == null)
- {
- throw new ArgumentNullException("queryString");
- }
-
- return queryString.GetUrl(ApiUrl + "/" + handler);
- }
-
- /// <summary>
- /// Creates a url to return a list of items
- /// </summary>
- /// <param name="query">The query.</param>
- /// <param name="listType">The type of list to retrieve.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">query</exception>
- protected string GetItemListUrl(ItemQuery query, string listType = null)
- {
- if (query == null)
- {
- throw new ArgumentNullException("query");
- }
-
- var dict = new QueryStringDictionary { };
-
- dict.AddIfNotNullOrEmpty("listtype", listType);
- dict.AddIfNotNullOrEmpty("ParentId", query.ParentId);
-
- dict.AddIfNotNull("startindex", query.StartIndex);
-
- dict.AddIfNotNull("limit", query.Limit);
-
- if (query.SortBy != null)
- {
- dict["sortBy"] = string.Join(",", query.SortBy.Select(s => s.ToString()));
- }
-
- if (query.SortOrder.HasValue)
- {
- dict["sortOrder"] = query.SortOrder.ToString();
- }
-
- if (query.Fields != null)
- {
- dict.Add("fields", query.Fields.Select(f => f.ToString()));
- }
- if (query.Filters != null)
- {
- dict.Add("Filters", query.Filters.Select(f => f.ToString()));
- }
- if (query.ImageTypes != null)
- {
- dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString()));
- }
-
- dict.Add("recursive", query.Recursive);
-
- dict.AddIfNotNull("genres", query.Genres);
- dict.AddIfNotNull("studios", query.Studios);
- dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes);
- dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes);
-
- dict.AddIfNotNullOrEmpty("person", query.Person);
- dict.AddIfNotNullOrEmpty("personType", query.PersonType);
-
- dict.AddIfNotNull("years", query.Years);
-
- dict.AddIfNotNullOrEmpty("indexBy", query.IndexBy);
- dict.AddIfNotNullOrEmpty("dynamicSortBy", query.DynamicSortBy);
- dict.AddIfNotNullOrEmpty("SearchTerm", query.SearchTerm);
-
- return GetApiUrl("Users/" + query.UserId + "/Items", dict);
- }
-
- /// <summary>
- /// Gets the image URL.
- /// </summary>
- /// <param name="baseUrl">The base URL.</param>
- /// <param name="options">The options.</param>
- /// <param name="queryParams">The query params.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">options</exception>
- private string GetImageUrl(string baseUrl, ImageOptions options, QueryStringDictionary queryParams)
- {
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- if (queryParams == null)
- {
- throw new ArgumentNullException("queryParams");
- }
-
- if (options.ImageIndex.HasValue)
- {
- baseUrl += "/" + options.ImageIndex.Value;
- }
-
- queryParams.AddIfNotNull("width", options.Width);
- queryParams.AddIfNotNull("height", options.Height);
- queryParams.AddIfNotNull("maxWidth", options.MaxWidth);
- queryParams.AddIfNotNull("maxHeight", options.MaxHeight);
- queryParams.AddIfNotNull("Quality", options.Quality);
-
- queryParams.AddIfNotNull("tag", options.Tag);
-
- return GetApiUrl(baseUrl, queryParams);
- }
-
- /// <summary>
- /// Gets the image URL.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetImageUrl(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- var index = options.ImageIndex ?? 0;
-
- if (options.ImageType == ImageType.Backdrop)
- {
- options.Tag = item.BackdropImageTags[index];
- }
- else if (options.ImageType == ImageType.ChapterImage)
- {
- options.Tag = item.Chapters[index].ImageTag;
- }
- else
- {
- options.Tag = item.ImageTags[options.ImageType];
- }
-
- return GetImageUrl(item.Id, options);
- }
-
- /// <summary>
- /// Gets an image url that can be used to download an image from the api
- /// </summary>
- /// <param name="itemId">The Id of the item</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">itemId</exception>
- public string GetImageUrl(string itemId, ImageOptions options)
- {
- if (string.IsNullOrEmpty(itemId))
- {
- throw new ArgumentNullException("itemId");
- }
-
- var url = "Items/" + itemId + "/Images/" + options.ImageType;
-
- return GetImageUrl(url, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the user image URL.
- /// </summary>
- /// <param name="user">The user.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">user</exception>
- public string GetUserImageUrl(UserDto user, ImageOptions options)
- {
- if (user == null)
- {
- throw new ArgumentNullException("user");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.Tag = user.PrimaryImageTag;
-
- return GetUserImageUrl(user.Id, options);
- }
-
- /// <summary>
- /// Gets an image url that can be used to download an image from the api
- /// </summary>
- /// <param name="userId">The Id of the user</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">userId</exception>
- public string GetUserImageUrl(Guid userId, ImageOptions options)
- {
- if (userId == Guid.Empty)
- {
- throw new ArgumentNullException("userId");
- }
-
- var url = "Users/" + userId + "/Images/" + options.ImageType;
-
- return GetImageUrl(url, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the person image URL.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetPersonImageUrl(BaseItemPerson item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.Tag = item.PrimaryImageTag;
-
- return GetPersonImageUrl(item.Name, options);
- }
-
- /// <summary>
- /// Gets the person image URL.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetPersonImageUrl(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.Tag = item.ImageTags[ImageType.Primary];
-
- return GetPersonImageUrl(item.Name, options);
- }
-
- /// <summary>
- /// Gets an image url that can be used to download an image from the api
- /// </summary>
- /// <param name="name">The name of the person</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">name</exception>
- public string GetPersonImageUrl(string name, ImageOptions options)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException("name");
- }
-
- var url = "Persons/" + name + "/Images/" + options.ImageType;
-
- return GetImageUrl(url, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the year image URL.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetYearImageUrl(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.Tag = item.ImageTags[ImageType.Primary];
-
- return GetYearImageUrl(int.Parse(item.Name), options);
- }
-
- /// <summary>
- /// Gets an image url that can be used to download an image from the api
- /// </summary>
- /// <param name="year">The year.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- public string GetYearImageUrl(int year, ImageOptions options)
- {
- var url = "Years/" + year + "/Images/" + options.ImageType;
-
- return GetImageUrl(url, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the genre image URL.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetGenreImageUrl(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.Tag = item.ImageTags[ImageType.Primary];
-
- return GetGenreImageUrl(item.Name, options);
- }
-
- /// <summary>
- /// Gets an image url that can be used to download an image from the api
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">name</exception>
- public string GetGenreImageUrl(string name, ImageOptions options)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException("name");
- }
-
- var url = "Genres/" + name + "/Images/" + options.ImageType;
-
- return GetImageUrl(url, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the studio image URL.
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetStudioImageUrl(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.Tag = item.ImageTags[ImageType.Primary];
-
- return GetStudioImageUrl(item.Name, options);
- }
-
- /// <summary>
- /// Gets an image url that can be used to download an image from the api
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">name</exception>
- public string GetStudioImageUrl(string name, ImageOptions options)
- {
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException("name");
- }
-
- var url = "Studios/" + name + "/Images/" + options.ImageType;
-
- return GetImageUrl(url, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// This is a helper to get a list of backdrop url's from a given ApiBaseItemWrapper. If the actual item does not have any backdrops it will return backdrops from the first parent that does.
- /// </summary>
- /// <param name="item">A given item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String[][].</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string[] GetBackdropImageUrls(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.ImageType = ImageType.Backdrop;
-
- string backdropItemId;
- List<Guid> backdropImageTags;
-
- if (item.BackdropCount == 0)
- {
- backdropItemId = item.ParentBackdropItemId;
- backdropImageTags = item.ParentBackdropImageTags;
- }
- else
- {
- backdropItemId = item.Id;
- backdropImageTags = item.BackdropImageTags;
- }
-
- if (string.IsNullOrEmpty(backdropItemId))
- {
- return new string[] { };
- }
-
- var files = new string[backdropImageTags.Count];
-
- for (var i = 0; i < backdropImageTags.Count; i++)
- {
- options.ImageIndex = i;
- options.Tag = backdropImageTags[i];
-
- files[i] = GetImageUrl(backdropItemId, options);
- }
-
- return files;
- }
-
- /// <summary>
- /// This is a helper to get the logo image url from a given ApiBaseItemWrapper. If the actual item does not have a logo, it will return the logo from the first parent that does, or null.
- /// </summary>
- /// <param name="item">A given item.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">item</exception>
- public string GetLogoImageUrl(BaseItemDto item, ImageOptions options)
- {
- if (item == null)
- {
- throw new ArgumentNullException("item");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- options.ImageType = ImageType.Logo;
-
- var logoItemId = item.HasLogo ? item.Id : item.ParentLogoItemId;
- var imageTag = item.HasLogo ? item.ImageTags[ImageType.Logo] : item.ParentLogoImageTag;
-
- if (!string.IsNullOrEmpty(logoItemId))
- {
- options.Tag = imageTag;
-
- return GetImageUrl(logoItemId, options);
- }
-
- return null;
- }
-
- /// <summary>
- /// Gets the url needed to stream an audio file
- /// </summary>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">options</exception>
- public string GetAudioStreamUrl(StreamOptions options)
- {
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- var handler = "Audio/" + options.ItemId + "/stream";
-
- if (!string.IsNullOrEmpty(options.OutputFileExtension))
- {
- handler += "." + options.OutputFileExtension.TrimStart('.');
- }
-
- return GetMediaStreamUrl(handler, options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Gets the url needed to stream a video file
- /// </summary>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">options</exception>
- public string GetVideoStreamUrl(VideoStreamOptions options)
- {
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- var handler = "Videos/" + options.ItemId + "/stream";
-
- if (!string.IsNullOrEmpty(options.OutputFileExtension))
- {
- handler += "." + options.OutputFileExtension.TrimStart('.');
- }
-
- return GetVideoStreamUrl(handler, options);
- }
-
- /// <summary>
- /// Formulates a url for streaming audio using the HLS protocol
- /// </summary>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">options</exception>
- public string GetHlsAudioStreamUrl(StreamOptions options)
- {
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- return GetMediaStreamUrl("audio.m3u8", options, new QueryStringDictionary());
- }
-
- /// <summary>
- /// Formulates a url for streaming video using the HLS protocol
- /// </summary>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">options</exception>
- public string GetHlsVideoStreamUrl(VideoStreamOptions options)
- {
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- return GetVideoStreamUrl("video.m3u8", options);
- }
-
- /// <summary>
- /// Gets the video stream URL.
- /// </summary>
- /// <param name="handler">The handler.</param>
- /// <param name="options">The options.</param>
- /// <returns>System.String.</returns>
- private string GetVideoStreamUrl(string handler, VideoStreamOptions options)
- {
- var queryParams = new QueryStringDictionary();
-
- if (options.VideoCodec.HasValue)
- {
- queryParams["VideoCodec"] = options.VideoCodec.Value.ToString();
- }
-
- queryParams.AddIfNotNull("VideoBitRate", options.VideoBitRate);
- queryParams.AddIfNotNull("Width", options.Width);
- queryParams.AddIfNotNull("Height", options.Height);
- queryParams.AddIfNotNull("MaxWidth", options.MaxWidth);
- queryParams.AddIfNotNull("MaxHeight", options.MaxHeight);
- queryParams.AddIfNotNull("FrameRate", options.FrameRate);
- queryParams.AddIfNotNull("AudioStreamIndex", options.AudioStreamIndex);
- queryParams.AddIfNotNull("VideoStreamIndex", options.VideoStreamIndex);
- queryParams.AddIfNotNull("SubtitleStreamIndex", options.SubtitleStreamIndex);
-
- return GetMediaStreamUrl(handler, options, queryParams);
- }
-
- /// <summary>
- /// Gets the media stream URL.
- /// </summary>
- /// <param name="handler">The handler.</param>
- /// <param name="options">The options.</param>
- /// <param name="queryParams">The query params.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">handler</exception>
- private string GetMediaStreamUrl(string handler, StreamOptions options, QueryStringDictionary queryParams)
- {
- if (string.IsNullOrEmpty(handler))
- {
- throw new ArgumentNullException("handler");
- }
-
- if (options == null)
- {
- throw new ArgumentNullException("options");
- }
-
- if (queryParams == null)
- {
- throw new ArgumentNullException("queryParams");
- }
-
- if (options.AudioCodec.HasValue)
- {
- queryParams["audioCodec"] = options.AudioCodec.Value.ToString();
- }
-
- queryParams.AddIfNotNull("audiochannels", options.MaxAudioChannels);
- queryParams.AddIfNotNull("audiosamplerate", options.MaxAudioSampleRate);
- queryParams.AddIfNotNull("AudioBitRate", options.AudioBitRate);
- queryParams.AddIfNotNull("StartTimeTicks", options.StartTimeTicks);
- queryParams.AddIfNotNull("Static", options.Static);
-
- return GetApiUrl(handler, queryParams);
- }
-
- /// <summary>
- /// Deserializes from stream.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="stream">The stream.</param>
- /// <returns>``0.</returns>
- protected T DeserializeFromStream<T>(Stream stream)
- where T : class
- {
- return (T)DeserializeFromStream(stream, typeof(T), SerializationFormat);
- }
-
- /// <summary>
- /// Deserializes from stream.
- /// </summary>
- /// <param name="stream">The stream.</param>
- /// <param name="type">The type.</param>
- /// <param name="format">The format.</param>
- /// <returns>System.Object.</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- protected object DeserializeFromStream(Stream stream, Type type, SerializationFormats format)
- {
- if (format == SerializationFormats.Protobuf)
- {
- return ProtobufSerializer.DeserializeFromStream(stream, type);
- }
- if (format == SerializationFormats.Json)
- {
- return JsonSerializer.DeserializeFromStream(stream, type);
- }
-
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Serializers to json.
- /// </summary>
- /// <param name="obj">The obj.</param>
- /// <returns>System.String.</returns>
- protected string SerializeToJson(object obj)
- {
- return JsonSerializer.SerializeToString(obj);
- }
-
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- /// <summary>
- /// Releases unmanaged and - optionally - managed resources.
- /// </summary>
- /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
- protected virtual void Dispose(bool disposing)
- {
-
- }
- }
-}
diff --git a/MediaBrowser.ApiInteraction/IAsyncHttpClient.cs b/MediaBrowser.ApiInteraction/IAsyncHttpClient.cs
deleted file mode 100644
index 0837f150f..000000000
--- a/MediaBrowser.ApiInteraction/IAsyncHttpClient.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using MediaBrowser.Model.Logging;
-using System;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.ApiInteraction
-{
- /// <summary>
- /// Interface IHttpClient
- /// </summary>
- public interface IAsyncHttpClient : IDisposable
- {
- /// <summary>
- /// Sets the authorization header that should be supplied on every request
- /// </summary>
- /// <param name="header"></param>
- void SetAuthorizationHeader(string header);
-
- /// <summary>
- /// Gets the stream async.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{Stream}.</returns>
- Task<Stream> GetAsync(string url, ILogger logger, CancellationToken cancellationToken);
-
- /// <summary>
- /// Deletes the async.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task.</returns>
- Task DeleteAsync(string url, ILogger logger, CancellationToken cancellationToken);
-
- /// <summary>
- /// Posts the async.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="contentType">Type of the content.</param>
- /// <param name="postContent">Content of the post.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task{Stream}.</returns>
- Task<Stream> PostAsync(string url, string contentType, string postContent, ILogger logger, CancellationToken cancellationToken);
- }
-}
diff --git a/MediaBrowser.ApiInteraction/MediaBrowser.ApiInteraction.csproj b/MediaBrowser.ApiInteraction/MediaBrowser.ApiInteraction.csproj
deleted file mode 100644
index ceb8aaece..000000000
--- a/MediaBrowser.ApiInteraction/MediaBrowser.ApiInteraction.csproj
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<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')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>MediaBrowser.ApiInteraction</RootNamespace>
- <AssemblyName>MediaBrowser.ApiInteraction</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
- <RestorePackages>true</RestorePackages>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Newtonsoft.Json">
- <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Net" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="..\SharedVersion.cs">
- <Link>Properties\SharedVersion.cs</Link>
- </Compile>
- <Compile Include="AsyncHttpClient.cs" />
- <Compile Include="BaseApiClient.cs" />
- <Compile Include="ApiClient.cs" />
- <Compile Include="IAsyncHttpClient.cs" />
- <Compile Include="NewtonsoftJsonSerializer.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SerializationFormats.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
- <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
- <Name>MediaBrowser.Model</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="packages.config" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
- <PropertyGroup>
- <PostBuildEvent>if $(ConfigurationName) == Release (
-xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i
-)</PostBuildEvent>
- </PropertyGroup>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
diff --git a/MediaBrowser.ApiInteraction/NewtonsoftJsonSerializer.cs b/MediaBrowser.ApiInteraction/NewtonsoftJsonSerializer.cs
deleted file mode 100644
index f5b43669e..000000000
--- a/MediaBrowser.ApiInteraction/NewtonsoftJsonSerializer.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using MediaBrowser.Model.Serialization;
-using Newtonsoft.Json;
-using System;
-using System.IO;
-
-namespace MediaBrowser.ApiInteraction
-{
- /// <summary>
- /// Class NewtonsoftJsonSerializer
- /// </summary>
- public class NewtonsoftJsonSerializer : IJsonSerializer
- {
- /// <summary>
- /// Serializes to stream.
- /// </summary>
- /// <param name="obj">The obj.</param>
- /// <param name="stream">The stream.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- /// <exception cref="System.ArgumentNullException">obj</exception>
- public void SerializeToStream(object obj, Stream stream)
- {
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Deserializes from stream.
- /// </summary>
- /// <param name="stream">The stream.</param>
- /// <param name="type">The type.</param>
- /// <returns>System.Object.</returns>
- public object DeserializeFromStream(Stream stream, Type type)
- {
- using (var streamReader = new StreamReader(stream))
- {
- using (var jsonReader = new JsonTextReader(streamReader))
- {
- return JsonSerializer.Create(new JsonSerializerSettings()).Deserialize(jsonReader, type);
- }
- }
- }
-
- /// <summary>
- /// Deserializes from stream.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="stream">The stream.</param>
- /// <returns>``0.</returns>
- public T DeserializeFromStream<T>(Stream stream)
- {
- return (T)DeserializeFromStream(stream, typeof(T));
- }
-
- /// <summary>
- /// Deserializes from string.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="text">The text.</param>
- /// <returns>``0.</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- public T DeserializeFromString<T>(string text)
- {
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Deserializes from string.
- /// </summary>
- /// <param name="json">The json.</param>
- /// <param name="type">The type.</param>
- /// <returns>System.Object.</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- public object DeserializeFromString(string json, Type type)
- {
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Serializes to string.
- /// </summary>
- /// <param name="obj">The obj.</param>
- /// <returns>System.String.</returns>
- public string SerializeToString(object obj)
- {
- using (var streamWriter = new StringWriter())
- {
- using (var jsonWriter = new JsonTextWriter((streamWriter)))
- {
- JsonSerializer.Create(new JsonSerializerSettings()).Serialize(jsonWriter, obj);
- }
- return streamWriter.ToString();
- }
- }
-
- /// <summary>
- /// Serializes to bytes.
- /// </summary>
- /// <param name="obj">The obj.</param>
- /// <returns>System.Byte[][].</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- public byte[] SerializeToBytes(object obj)
- {
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Serializes to file.
- /// </summary>
- /// <param name="obj">The obj.</param>
- /// <param name="file">The file.</param>
- /// <exception cref="System.NotImplementedException"></exception>
- /// <exception cref="System.ArgumentNullException">obj</exception>
- public void SerializeToFile(object obj, string file)
- {
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Deserializes from file.
- /// </summary>
- /// <param name="type">The type.</param>
- /// <param name="file">The file.</param>
- /// <returns>System.Object.</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- public object DeserializeFromFile(Type type, string file)
- {
- throw new NotImplementedException();
- }
-
- /// <summary>
- /// Deserializes from file.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="file">The file.</param>
- /// <returns>``0.</returns>
- /// <exception cref="System.NotImplementedException"></exception>
- public T DeserializeFromFile<T>(string file) where T : class
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs b/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs
deleted file mode 100644
index e4ed8a6ad..000000000
--- a/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("MediaBrowser.ApiInteraction")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MediaBrowser.ApiInteraction")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("677618f2-de4b-44f4-8dfd-a90176297ee2")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-// \ No newline at end of file
diff --git a/MediaBrowser.ApiInteraction/SerializationFormats.cs b/MediaBrowser.ApiInteraction/SerializationFormats.cs
deleted file mode 100644
index 9bfba7c50..000000000
--- a/MediaBrowser.ApiInteraction/SerializationFormats.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-
-namespace MediaBrowser.ApiInteraction
-{
- /// <summary>
- /// Enum SerializationFormats
- /// </summary>
- public enum SerializationFormats
- {
- /// <summary>
- /// The json
- /// </summary>
- Json,
- /// <summary>
- /// The protobuf
- /// </summary>
- Protobuf
- }
-}
diff --git a/MediaBrowser.ApiInteraction/packages.config b/MediaBrowser.ApiInteraction/packages.config
deleted file mode 100644
index b82a8b0dd..000000000
--- a/MediaBrowser.ApiInteraction/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
index 4adff8380..831b111ec 100644
--- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
+++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
@@ -149,20 +149,48 @@
</ItemGroup>
<ItemGroup>
<Content Include="README.txt" />
- <Content Include="swagger-ui\css\screen.css" />
- <Content Include="swagger-ui\images\pet_store_api.png" />
- <Content Include="swagger-ui\images\wordnik_api.png" />
- <Content Include="swagger-ui\index.html" />
- <Content Include="swagger-ui\lib\backbone-min.js" />
- <Content Include="swagger-ui\lib\handlebars.runtime-1.0.0.beta.6.js" />
- <Content Include="swagger-ui\lib\jquery.ba-bbq.min.js" />
- <Content Include="swagger-ui\lib\jquery.min.js" />
- <Content Include="swagger-ui\lib\jquery.slideto.min.js" />
- <Content Include="swagger-ui\lib\jquery.wiggle.min.js" />
- <Content Include="swagger-ui\lib\swagger.js" />
- <Content Include="swagger-ui\lib\underscore-min.js" />
- <Content Include="swagger-ui\swagger-ui.js" />
- <Content Include="swagger-ui\swagger-ui.min.js" />
+ <Content Include="swagger-ui\css\screen.css">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\images\pet_store_api.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\images\wordnik_api.png">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\index.html">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\backbone-min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\handlebars.runtime-1.0.0.beta.6.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\jquery.ba-bbq.min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\jquery.min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\jquery.slideto.min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\jquery.wiggle.min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\swagger.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\lib\underscore-min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\swagger-ui.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="swagger-ui\swagger-ui.min.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/MediaBrowser.Common.Implementations/swagger-ui/index.html b/MediaBrowser.Common.Implementations/swagger-ui/index.html
index 5d2a8d88d..0b2b02b10 100644
--- a/MediaBrowser.Common.Implementations/swagger-ui/index.html
+++ b/MediaBrowser.Common.Implementations/swagger-ui/index.html
@@ -42,7 +42,7 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
- discoveryUrl:'../api/resources',
+ discoveryUrl:'../resources',
apiKey:"",
dom_id:"swagger-ui-container",
supportHeaderParams: false,
diff --git a/MediaBrowser.ServerApplication/App.config b/MediaBrowser.ServerApplication/App.config
index 4269ade64..13283e4b5 100644
--- a/MediaBrowser.ServerApplication/App.config
+++ b/MediaBrowser.ServerApplication/App.config
@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
- <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
+ <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<system.diagnostics>
<assert assertuienabled="false" />
</system.diagnostics>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <targets async="true">
- </targets>
+ <targets async="true"></targets>
</nlog>
<appSettings>
<add key="DebugProgramDataPath" value="..\..\..\..\ProgramData-Server" />
<add key="ReleaseProgramDataPath" value="%CommonApplicationData%" />
- <add key="ProgramDataFolderName" value="MediaBrowser-Server"/>
+ <add key="ProgramDataFolderName" value="MediaBrowser-Server" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
- <gcServer enabled ="true" />
+ <gcServer enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 230b26fa7..bc69c9664 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -128,18 +128,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\UPnP\Libs\Platinum.Managed.dll</HintPath>
</Reference>
- <Reference Include="ServiceStack.Common, Version=3.9.37.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\ServiceStack.Common.3.9.37\lib\net35\ServiceStack.Common.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.Interfaces, Version=3.9.37.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\ServiceStack.Common.3.9.37\lib\net35\ServiceStack.Interfaces.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.Text, Version=3.9.37.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\ServiceStack.Text.3.9.37\lib\net35\ServiceStack.Text.dll</HintPath>
- </Reference>
<Reference Include="SimpleInjector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SimpleInjector.2.0.0-beta5\lib\net40-client\SimpleInjector.dll</HintPath>
@@ -155,6 +143,9 @@
<HintPath>..\packages\System.Data.SQLite.1.0.84.0\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
+ <Reference Include="System.Net" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config
index 71e2844fc..e1beae6da 100644
--- a/MediaBrowser.ServerApplication/packages.config
+++ b/MediaBrowser.ServerApplication/packages.config
@@ -3,8 +3,6 @@
<package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
<package id="Hardcodet.Wpf.TaskbarNotification" version="1.0.4.0" targetFramework="net45" />
<package id="NLog" version="2.0.0.2000" targetFramework="net45" />
- <package id="ServiceStack.Common" version="3.9.37" targetFramework="net45" />
- <package id="ServiceStack.Text" version="3.9.37" targetFramework="net45" />
<package id="SimpleInjector" version="2.0.0-beta5" targetFramework="net45" />
<package id="System.Data.SQLite" version="1.0.84.0" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/MediaBrowser.sln b/MediaBrowser.sln
index e4299d034..b473b2062 100644
--- a/MediaBrowser.sln
+++ b/MediaBrowser.sln
@@ -20,10 +20,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Performance19.psess = Performance19.psess
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.ApiInteraction", "MediaBrowser.ApiInteraction\MediaBrowser.ApiInteraction.csproj", "{921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.ApiInteraction.Portable", "MediaBrowser.ApiInteraction.Portable\MediaBrowser.ApiInteraction.Portable.csproj", "{52E0C440-85C0-4A99-ACFE-07C87B2600BE}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget (2)", ".nuget (2)", "{E60FB157-87E2-4A41-8B04-27EA49B63B4D}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
@@ -155,36 +151,6 @@ Global
{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x64.ActiveCfg = Release|Any CPU
{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x86.ActiveCfg = Release|Any CPU
{5624B7B5-B5A7-41D8-9F10-CC5611109619}.Release|x86.Build.0 = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|x64.ActiveCfg = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|x86.ActiveCfg = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Debug|x86.Build.0 = Debug|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|Any CPU.Build.0 = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|Win32.ActiveCfg = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|x64.ActiveCfg = Release|Any CPU
- {921C0F64-FDA7-4E9F-9E73-0CB0EEDB2422}.Release|x86.ActiveCfg = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|x64.ActiveCfg = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|x86.ActiveCfg = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Debug|x86.Build.0 = Debug|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|Any CPU.Build.0 = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|Win32.ActiveCfg = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|x64.ActiveCfg = Release|Any CPU
- {52E0C440-85C0-4A99-ACFE-07C87B2600BE}.Release|x86.ActiveCfg = Release|Any CPU
{5356AE30-6A6E-4A64-81E3-F76C50595E64}.Debug|Any CPU.ActiveCfg = Debug|x86
{5356AE30-6A6E-4A64-81E3-F76C50595E64}.Debug|Any CPU.Build.0 = Debug|x86
{5356AE30-6A6E-4A64-81E3-F76C50595E64}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
diff --git a/Nuget/MediaBrowser.ApiClient.nuspec b/Nuget/MediaBrowser.ApiClient.nuspec
deleted file mode 100644
index 7f4894713..000000000
--- a/Nuget/MediaBrowser.ApiClient.nuspec
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
- <metadata>
- <id>MediaBrowser.ApiClient</id>
- <version>3.0.0.17-beta</version>
- <title>MediaBrowser.ApiClient</title>
- <authors>Media Browser Team</authors>
- <owners>scottisafool,Luke</owners>
- <requireLicenseAcceptance>false</requireLicenseAcceptance>
- <description>ApiClient allows .NET clients to easily access the Media Browser 3 web API</description>
- <copyright>Copyright © Media Browser 2013</copyright>
- <dependencies>
- <group targetFramework=".NETFramework4.5">
- <dependency id="Newtonsoft.Json" version="4.5.11" />
- </group>
- <group targetFramework=".NETPortable0.0-net45+sl4+wp71+win8">
- <dependency id="Newtonsoft.Json" version="4.5.11" />
- <dependency id="Microsoft.Bcl.Async" version="1.0.14-rc" />
- <dependency id="Microsoft.Net.Http" version="2.1.3-beta" />
- </group>
- </dependencies>
- </metadata>
- <files>
- <file src="dlls\MediaBrowser.ApiInteraction.dll" target="lib\net45\MediaBrowser.ApiInteraction.dll" />
- <file src="dlls\MediaBrowser.ApiInteraction.Portable.dll" target="lib\portable-net45+sl4+wp71+win8\MediaBrowser.ApiInteraction.Portable.dll" />
- </files>
-</package> \ No newline at end of file