aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Dto/DtoService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Dto/DtoService.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Dto/DtoService.cs40
1 files changed, 31 insertions, 9 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index 68d9a5e9b..bdc758d8e 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -132,13 +132,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{
if (options.Fields.Contains(ItemFields.ItemCounts))
{
- var itemFilter = byName.GetItemFilter();
-
- var libraryItems = user != null ?
- user.RootFolder.GetRecursiveChildren(user, itemFilter) :
- _libraryManager.RootFolder.GetRecursiveChildren(itemFilter);
-
- SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
+ SetItemByNameInfo(item, dto, GetTaggedItems(byName, user), user);
}
FillSyncInfo(dto, item, options, user, syncProgress);
@@ -150,6 +144,33 @@ namespace MediaBrowser.Server.Implementations.Dto
return dto;
}
+ private List<BaseItem> GetTaggedItems(IItemByName byName, User user)
+ {
+ var person = byName as Person;
+
+ if (person != null)
+ {
+ var items = _libraryManager.GetItems(new InternalItemsQuery
+ {
+ Person = byName.Name
+
+ }).Items;
+
+ if (user != null)
+ {
+ return items.Where(i => i.IsVisibleStandalone(user)).ToList();
+ }
+
+ return items.ToList();
+ }
+
+ var itemFilter = byName.GetItemFilter();
+
+ return user != null ?
+ user.RootFolder.GetRecursiveChildren(user, itemFilter).ToList() :
+ _libraryManager.RootFolder.GetRecursiveChildren(itemFilter).ToList();
+ }
+
private SyncedItemProgress[] GetSyncedItemProgress(DtoOptions options)
{
if (!options.Fields.Contains(ItemFields.SyncInfo))
@@ -636,7 +657,7 @@ namespace MediaBrowser.Server.Implementations.Dto
// Ordering by person type to ensure actors and artists are at the front.
// This is taking advantage of the fact that they both begin with A
// This should be improved in the future
- var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue)
+ var people = _libraryManager.GetPeople(item).OrderBy(i => i.SortOrder ?? int.MaxValue)
.ThenBy(i =>
{
if (i.IsType(PersonType.Actor))
@@ -684,7 +705,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
}).Where(i => i != null)
- .DistinctBy(i => i.Name)
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
for (var i = 0; i < people.Count; i++)
@@ -736,6 +757,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
})
.Where(i => i != null)
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
for (var i = 0; i < studios.Count; i++)