start people update

This commit is contained in:
Luke Pulverenti
2015-06-20 23:35:22 -04:00
parent 64bdf13434
commit 8bb10cb12f
34 changed files with 176 additions and 129 deletions

View File

@@ -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,26 @@ namespace MediaBrowser.Server.Implementations.Library
item.ExtraType = ExtraType.Clip;
}
}
public List<PersonInfo> GetPeople(BaseItem item)
{
return item.People ?? new List<PersonInfo>();
}
public List<PersonInfo> GetAllPeople()
{
return RootFolder.GetRecursiveChildren()
.SelectMany(GetPeople)
.Where(i => !string.IsNullOrWhiteSpace(i.Name))
.DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToList();
}
public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
{
item.People = people;
return item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None);
}
}
}

View File

@@ -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)

View File

@@ -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);