From 6a3b31a1b059ca076405598d6eca98923c1e991a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 15 Oct 2013 18:16:39 -0400 Subject: [PATCH] added IncludeIndexContainer --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 29 +++++++++++++++---- .../Providers/BaseMetadataProvider.cs | 2 +- MediaBrowser.Model/Querying/ItemQuery.cs | 6 ++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 6a8992658..d55ba2e90 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -179,6 +179,8 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "IsHD", Description = "Optional filter by items that are HD or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsHD { get; set; } + + public bool IncludeIndexContainers { get; set; } } /// @@ -285,20 +287,37 @@ namespace MediaBrowser.Api.UserLibrary var item = string.IsNullOrEmpty(request.ParentId) ? user.RootFolder : _dtoService.GetItemByDtoId(request.ParentId, user.Id); // Default list type = children + IEnumerable items; if (!string.IsNullOrEmpty(request.Ids)) { var idList = request.Ids.Split(',').ToList(); - return idList.Select(i => _dtoService.GetItemByDtoId(i, user.Id)); + items = idList.Select(i => _dtoService.GetItemByDtoId(i, user.Id)); } - if (request.Recursive) + else if (request.Recursive) { - return ((Folder)item).GetRecursiveChildren(user); + items = ((Folder) item).GetRecursiveChildren(user); + } + else + { + items = ((Folder)item).GetChildren(user, true, request.IndexBy); } - return ((Folder)item).GetChildren(user, true, request.IndexBy); + if (request.IncludeIndexContainers) + { + var list = items.ToList(); + + var containers = list.Select(i => i.IndexContainer) + .Where(i => i != null); + + list.AddRange(containers); + + return list.Distinct(); + } + + return items; } /// @@ -648,7 +667,7 @@ namespace MediaBrowser.Api.UserLibrary if (string.IsNullOrEmpty(personTypes)) { - items = items.Where(item => item.People != null && item.People.Any(p => string.Equals(p.Name, request.Person, StringComparison.OrdinalIgnoreCase))); + items = items.Where(item => item.People.Any(p => string.Equals(p.Name, request.Person, StringComparison.OrdinalIgnoreCase))); } else { diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs index 10c5c116a..ee854018b 100644 --- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs +++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs @@ -406,7 +406,7 @@ namespace MediaBrowser.Controller.Providers return sb.ToString().GetMD5(); } - private static readonly Dictionary FoldersToMonitor = new[] { "extrafanart" } + private static readonly Dictionary FoldersToMonitor = new[] { "extrafanart", "extrathumbs" } .ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); /// diff --git a/MediaBrowser.Model/Querying/ItemQuery.cs b/MediaBrowser.Model/Querying/ItemQuery.cs index db0cc4928..76269c56c 100644 --- a/MediaBrowser.Model/Querying/ItemQuery.cs +++ b/MediaBrowser.Model/Querying/ItemQuery.cs @@ -229,6 +229,12 @@ namespace MediaBrowser.Model.Querying /// /// The album artist starts with or greater. public string AlbumArtistStartsWithOrGreater { get; set; } + + /// + /// Gets or sets a value indicating whether [include index containers]. + /// + /// true if [include index containers]; otherwise, false. + public bool IncludeIndexContainers { get; set; } /// /// Initializes a new instance of the class.