The Free Software Media System - Server Backend & API
web client re-org
Luke Pulverentic7c72dd1a892
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.csindex ba42f3030d..5d4055abf4 100644--- a/MediaBrowser.Api/BaseApiService.cs+++ b/MediaBrowser.Api/BaseApiService.cs@@ -154,8 +154,14 @@ namespace MediaBrowser.Apireturn libraryManager.GetPerson(DeSlugPersonName(name, libraryManager));}- protected IList<BaseItem> GetAllLibraryItems(Guid? userId, IUserManager userManager, ILibraryManager libraryManager)+ protected IList<BaseItem> GetAllLibraryItems(Guid? userId, IUserManager userManager, ILibraryManager libraryManager, string parentId = null){+ if (!string.IsNullOrEmpty(parentId))+ {+ var folder = (Folder) libraryManager.GetItemById(new Guid(parentId));++ return folder.GetRecursiveChildren();+ }if (userId.HasValue){var user = userManager.GetUserById(userId.Value);diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.csindex 52563abfde..2851428009 100644--- a/MediaBrowser.Api/Movies/MoviesService.cs+++ b/MediaBrowser.Api/Movies/MoviesService.cs@@ -45,6 +45,13 @@ namespace MediaBrowser.Api.Movies[ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public Guid? UserId { get; set; }+ /// <summary>+ /// Specify this to localize the search to a specific item or folder. Omit to use the root.+ /// </summary>+ /// <value>The parent id.</value>+ [ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string ParentId { get; set; }+public GetMovieRecommendations(){CategoryLimit = 5;@@ -117,7 +124,9 @@ namespace MediaBrowser.Api.Movies{var user = _userManager.GetUserById(request.UserId.Value);- var movies = user.RootFolder.GetRecursiveChildren(user).OfType<Movie>().ToList();+ var movies = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId)+ .OfType<Movie>()+ .ToList();var result = GetRecommendationCategories(user, movies, request.CategoryLimit, request.ItemLimit, request.GetItemFields().ToList());diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.csindex 7fa586a7d7..73e823a2c7 100644--- a/MediaBrowser.Api/TvShowsService.cs+++ b/MediaBrowser.Api/TvShowsService.cs@@ -50,6 +50,13 @@ namespace MediaBrowser.Api[ApiMember(Name = "SeriesId", Description = "Optional. Filter by series id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string SeriesId { get; set; }++ /// <summary>+ /// Specify this to localize the search to a specific item or folder. Omit to use the root.+ /// </summary>+ /// <value>The parent id.</value>+ [ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string ParentId { get; set; }}[Route("/Shows/Upcoming", "GET", Summary = "Gets a list of upcoming episodes")]@@ -82,6 +89,13 @@ namespace MediaBrowser.Api/// <value>The fields.</value>[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]public string Fields { get; set; }++ /// <summary>+ /// Specify this to localize the search to a specific item or folder. Omit to use the root.+ /// </summary>+ /// <value>The parent id.</value>+ [ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string ParentId { get; set; }}[Route("/Shows/{Id}/Similar", "GET", Summary = "Finds tv shows similar to a given one.")]@@ -218,7 +232,7 @@ namespace MediaBrowser.Api{var user = _userManager.GetUserById(request.UserId);- var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager)+ var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId).OfType<Episode>();var itemsList = _libraryManager.Sort(items, user, new[] { "PremiereDate", "AirTime", "SortName" }, SortOrder.Ascending)@@ -276,10 +290,7 @@ namespace MediaBrowser.Apipublic IEnumerable<Episode> GetNextUpEpisodes(GetNextUpEpisodes request){- var user = _userManager.GetUserById(request.UserId);-- var items = user.RootFolder- .GetRecursiveChildren(user)+ var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId).OfType<Series>();// Avoid implicitly captured closurediff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.csindex e24daf8538..48a639d4d4 100644--- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs+++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs@@ -138,12 +138,23 @@ namespace MediaBrowser.Controller.Providers{// DateCreatedcase "Added":- DateTime added;- if (DateTime.TryParse(reader.ReadElementContentAsString() ?? string.Empty, out added)){- item.DateCreated = added.ToUniversalTime();+ var val = reader.ReadElementContentAsString();++ if (!string.IsNullOrWhiteSpace(val))+ {+ DateTime added;+ if (DateTime.TryParse(val, out added))+ {+ item.DateCreated = added.ToUniversalTime();+ }+ else+ {+ Logger.Warn("Invalid Added value found: " + val);+ }+ }+ break;}- break;case "LocalTitle":item.Name = reader.ReadElementContentAsString();diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csprojindex b9a8323fb4..e129468d39 100644--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj+++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj@@ -80,7 +80,13 @@<None Include="packages.config" /></ItemGroup><Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />-+ <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">+ <PropertyGroup>+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>+ </PropertyGroup>+ <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />+ </Target><!-- 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">diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.csindex fafcc5fad2..67536ac5ff 100644--- a/MediaBrowser.Providers/Manager/ProviderUtils.cs+++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs@@ -1,4 +1,5 @@-using MediaBrowser.Controller.Entities;+using System;+using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Entities.Audio;using MediaBrowser.Model.Entities;using System.Collections.Generic;@@ -186,6 +187,12 @@ namespace MediaBrowser.Providers.Managertarget.IsLocked = source.IsLocked;target.DisplayMediaType = source.DisplayMediaType;+ // Grab the value if it's there, but if not then don't overwrite the default+ if (source.DateCreated != default(DateTime))+ {+ target.DateCreated = source.DateCreated;+ }+var sourceHasLanguageSettings = source as IHasPreferredMetadataLanguage;var targetHasLanguageSettings = target as IHasPreferredMetadataLanguage;diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.csindex 098d1295f1..04ddb4c4b1 100644--- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs+++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs@@ -3,8 +3,6 @@ using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Plugins;using MediaBrowser.Model.Logging;using Mono.Nat;-using Mono.Nat.Enums;-using Mono.Nat.EventArgs;using System;using System.IO;using System.Text;@@ -19,9 +17,9 @@ namespace MediaBrowser.Server.Implementations.EntryPointsprivate bool _isStarted;- public ExternalPortForwarding(ILogger logger, IServerApplicationHost appHost, IServerConfigurationManager config)+ public ExternalPortForwarding(ILogManager logmanager, IServerApplicationHost appHost, IServerConfigurationManager config){- _logger = logger;+ _logger = logmanager.GetLogger("PortMapper");_appHost = appHost;_config = config;diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.csindex 009e4716dc..cfe5ef4f05 100644--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs@@ -1,4 +1,5 @@using System.Net.Sockets;+using System.Runtime.Serialization;using Funq;using MediaBrowser.Common;using MediaBrowser.Common.Extensions;@@ -246,8 +247,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer_autoResetEvents[index].Set();}- if (context == null) return;-var date = DateTime.Now;Task.Factory.StartNew(async () =>@@ -375,7 +374,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer};var operationName = context.Request.GetOperationName();- var httpReq = context.ToRequest(operationName);+ var httpReq = GetRequest(context, operationName);var httpRes = httpReq.Response;var contentType = httpReq.ResponseContentType;@@ -409,6 +408,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer}}+ private static ListenerRequest GetRequest(HttpListenerContext httpContext, string operationName)+ {+ var req = new ListenerRequest(httpContext, operationName, RequestAttributes.None);+ req.RequestAttributes = req.GetAttributes();+ return req;+ }+/// <summary>/// Shut down the Web Service/// </summary>@@ -436,7 +442,7 @@ namespace MediaBrowser.Server.Implementations.HttpServervar operationName = context.Request.GetOperationName();- var httpReq = context.ToRequest(operationName);+ var httpReq = GetRequest(context, operationName);var httpRes = httpReq.Response;var handler = HttpHandlerFactory.GetHandler(httpReq);diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.jsonindex 72c3410575..9d9a6b0a94 100644--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json@@ -620,5 +620,6 @@"NotificationOptionPluginError": "Plugin failure","ButtonVolumeUp": "Volume up","ButtonVolumeDown": "Volume down",- "ButtonMute": "Mute"+ "ButtonMute": "Mute",+ "HeaderLatestMedia": "Latest Media"}\ No newline at end of filediff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csprojindex d86ff8aac0..6e5e58d26c 100644--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj@@ -48,9 +48,9 @@<Reference Include="Alchemy"><HintPath>..\packages\Alchemy.2.2.1\lib\net40\Alchemy.dll</HintPath></Reference>- <Reference Include="Mono.Nat, Version=1.2.3.0, Culture=neutral, processorArchitecture=MSIL">+ <Reference Include="Mono.Nat, Version=1.2.7.0, Culture=neutral, processorArchitecture=MSIL"><SpecificVersion>False</SpecificVersion>- <HintPath>..\packages\Mono.Nat.1.2.3\lib\Net40\Mono.Nat.dll</HintPath>+ <HintPath>..\packages\Mono.Nat.1.2.7.0\lib\net40\Mono.Nat.dll</HintPath></Reference><Reference Include="ServiceStack.Api.Swagger"><HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath>diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.configindex d82e880c98..9b44f9c618 100644--- a/MediaBrowser.Server.Implementations/packages.config+++ b/MediaBrowser.Server.Implementations/packages.config@@ -1,7 +1,7 @@<?xml version="1.0" encoding="utf-8"?><packages><package id="Alchemy" version="2.2.1" targetFramework="net45" />- <package id="Mono.Nat" version="1.2.3" targetFramework="net45" />+ <package id="Mono.Nat" version="1.2.7.0" targetFramework="net45" /><package id="morelinq" version="1.0.16006" targetFramework="net45" /><package id="System.Data.SQLite.Core" version="1.0.91.3" targetFramework="net45" /></packages>\ No newline at end of filediff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.csindex e1d3cda40c..b849c7a440 100644--- a/MediaBrowser.Server.Mono/Program.cs+++ b/MediaBrowser.Server.Mono/Program.cs@@ -41,10 +41,8 @@ namespace MediaBrowser.Server.Monovar applicationPath = Assembly.GetEntryAssembly ().Location;#endif- var commandArgs = Environment.GetCommandLineArgs();-// Allow this to be specified on the command line.- var customProgramDataPath = commandArgs.ElementAtOrDefault(1);+ var customProgramDataPath = ParseCommandLine();var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath);@@ -75,6 +73,20 @@ namespace MediaBrowser.Server.Mono_appHost.Dispose();}}++ private static string ParseCommandLine()+ {+ var commandArgs = Environment.GetCommandLineArgs().ToList();++ var programDataPathIndex = commandArgs.IndexOf("-programdata");++ if (programDataPathIndex != -1)+ {+ return commandArgs.ElementAtOrDefault(programDataPathIndex + 1);+ }++ return null;+ }private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, string programDataPath){