diff options
12 files changed, 95 insertions, 28 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index ba42f3030..5d4055abf 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -154,8 +154,14 @@ namespace MediaBrowser.Api return 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.cs index 52563abfd..285142800 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.cs index 7fa586a7d..73e823a2c 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.Api public 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 closure diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index e24daf853..48a639d4d 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -138,12 +138,23 @@ namespace MediaBrowser.Controller.Providers { // DateCreated case "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.csproj index b9a8323fb..e129468d3 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.cs index fafcc5fad..67536ac5f 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.Manager target.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.cs index 098d1295f..04ddb4c4b 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.EntryPoints private 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.cs index 009e4716d..cfe5ef4f0 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.HttpServer var 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.json index 72c341057..9d9a6b0a9 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 file diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index d86ff8aac..6e5e58d26 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.config index d82e880c9..9b44f9c61 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 file diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index e1d3cda40..b849c7a44 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -41,10 +41,8 @@ namespace MediaBrowser.Server.Mono var 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) { |
