From c7c72dd1a89217f48cb48db93d9ee1fa5ee6171d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 1 May 2014 22:54:33 -0400 Subject: [PATCH] web client re-org --- MediaBrowser.Api/BaseApiService.cs | 8 ++++++- MediaBrowser.Api/Movies/MoviesService.cs | 11 +++++++++- MediaBrowser.Api/TvShowsService.cs | 21 ++++++++++++++----- .../Providers/BaseItemXmlParser.cs | 19 +++++++++++++---- .../MediaBrowser.MediaEncoding.csproj | 8 ++++++- .../Manager/ProviderUtils.cs | 9 +++++++- .../EntryPoints/ExternalPortForwarding.cs | 6 ++---- .../HttpServer/HttpListenerHost.cs | 14 +++++++++---- .../Localization/Server/server.json | 3 ++- ...MediaBrowser.Server.Implementations.csproj | 4 ++-- .../packages.config | 2 +- MediaBrowser.Server.Mono/Program.cs | 18 +++++++++++++--- 12 files changed, 95 insertions(+), 28 deletions(-) diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index ba42f3030d..5d4055abf4 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 GetAllLibraryItems(Guid? userId, IUserManager userManager, ILibraryManager libraryManager) + protected IList 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 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; } + /// + /// Specify this to localize the search to a specific item or folder. Omit to use the root. + /// + /// The parent id. + [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().ToList(); + var movies = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId) + .OfType() + .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 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; } + + /// + /// Specify this to localize the search to a specific item or folder. Omit to use the root. + /// + /// The parent id. + [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 /// The fields. [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; } + + /// + /// Specify this to localize the search to a specific item or folder. Omit to use the root. + /// + /// The parent id. + [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(); var itemsList = _libraryManager.Sort(items, user, new[] { "PremiereDate", "AirTime", "SortName" }, SortOrder.Ascending) @@ -276,10 +290,7 @@ namespace MediaBrowser.Api public IEnumerable 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(); // Avoid implicitly captured closure diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index e24daf8538..48a639d4d4 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 b9a8323fb4..e129468d39 100644 --- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj +++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj @@ -80,7 +80,13 @@ - + + + + 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}. + + +