aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library
diff options
context:
space:
mode:
authorTavares André <tavares_and@hotmail.com>2015-06-30 20:26:42 +0200
committerTavares André <tavares_and@hotmail.com>2015-06-30 20:26:42 +0200
commit27d6135493c778bddee6ad6e044ed167c6449d7d (patch)
tree4cf323758d3e9caf115c9627f8e6da7dd78c543f /MediaBrowser.Server.Implementations/Library
parent1e07dbec63bced51857e67b00941b91ca86a7f77 (diff)
parent86571a629764be30e6d2e671db9e87c42a72a7f4 (diff)
Merge branch 'dev' of https://github.com/MediaBrowser/MediaBrowser into dev
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs27
-rw-r--r--MediaBrowser.Server.Implementations/Library/SearchEngine.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs38
3 files changed, 29 insertions, 38 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index ed5dde4c5..c5171e323 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -32,6 +32,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MoreLinq;
using SortOrder = MediaBrowser.Model.Entities.SortOrder;
namespace MediaBrowser.Server.Implementations.Library
@@ -2055,5 +2056,31 @@ namespace MediaBrowser.Server.Implementations.Library
item.ExtraType = ExtraType.Clip;
}
}
+
+
+ public List<PersonInfo> GetPeople(BaseItem item)
+ {
+ return item.People ?? ItemRepository.GetPeople(item.Id);
+ }
+
+ public List<PersonInfo> GetAllPeople()
+ {
+ return RootFolder.GetRecursiveChildren()
+ .SelectMany(GetPeople)
+ .Where(i => !string.IsNullOrWhiteSpace(i.Name))
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
+ .ToList();
+ }
+
+ public async Task UpdatePeople(BaseItem item, List<PersonInfo> people)
+ {
+ await ItemRepository.UpdatePeople(item.Id, people).ConfigureAwait(false);
+
+ if (item.People != null)
+ {
+ item.People = null;
+ await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
+ }
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
index 72bbefae4..0cfa524eb 100644
--- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
+++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
@@ -257,7 +257,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (query.IncludePeople)
{
// Find persons
- var persons = items.SelectMany(i => i.People)
+ var persons = items.SelectMany(i => _libraryManager.GetPeople(i))
.Select(i => i.Name)
.Where(i => !string.IsNullOrWhiteSpace(i))
.Distinct(StringComparer.OrdinalIgnoreCase)
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
index 059ad2481..ef9dee8b5 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
@@ -72,39 +72,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
return options.DownloadOtherPeopleMetadata;
}
- private IEnumerable<PersonInfo> GetPeopleToValidate(BaseItem item, PeopleMetadataOptions options)
- {
- return item.People.Where(i =>
- {
- if (i.IsType(PersonType.Actor))
- {
- return options.DownloadActorMetadata;
- }
- if (i.IsType(PersonType.Director))
- {
- return options.DownloadDirectorMetadata;
- }
- if (i.IsType(PersonType.Composer))
- {
- return options.DownloadComposerMetadata;
- }
- if (i.IsType(PersonType.Writer))
- {
- return options.DownloadWriterMetadata;
- }
- if (i.IsType(PersonType.Producer))
- {
- return options.DownloadProducerMetadata;
- }
- if (i.IsType(PersonType.GuestStar))
- {
- return options.DownloadGuestStarMetadata;
- }
-
- return options.DownloadOtherPeopleMetadata;
- });
- }
-
/// <summary>
/// Validates the people.
/// </summary>
@@ -119,10 +86,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var peopleOptions = _config.Configuration.PeopleMetadataOptions;
- var people = _libraryManager.RootFolder.GetRecursiveChildren()
- .SelectMany(i => i.People)
- .Where(i => !string.IsNullOrWhiteSpace(i.Name))
- .ToList();
+ var people = _libraryManager.GetAllPeople();
var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);