diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 014b3ae6a..6e8c9ae54 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -413,15 +413,6 @@ namespace MediaBrowser.Controller.Entities
}
}
- public bool ContainsPerson(string name)
- {
- if (string.IsNullOrWhiteSpace(name))
- {
- throw new ArgumentNullException("name");
- }
- return People.Any(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
- }
-
public string GetInternalMetadataPath()
{
var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;
@@ -1248,83 +1239,7 @@ namespace MediaBrowser.Controller.Entities
///
public void AddPerson(PersonInfo person)
{
- if (person == null)
- {
- throw new ArgumentNullException("person");
- }
-
- if (string.IsNullOrWhiteSpace(person.Name))
- {
- throw new ArgumentNullException();
- }
-
- // Normalize
- if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
- {
- person.Type = PersonType.GuestStar;
- }
- else if (string.Equals(person.Role, PersonType.Director, StringComparison.OrdinalIgnoreCase))
- {
- person.Type = PersonType.Director;
- }
- else if (string.Equals(person.Role, PersonType.Producer, StringComparison.OrdinalIgnoreCase))
- {
- person.Type = PersonType.Producer;
- }
- else if (string.Equals(person.Role, PersonType.Writer, StringComparison.OrdinalIgnoreCase))
- {
- person.Type = PersonType.Writer;
- }
-
- // If the type is GuestStar and there's already an Actor entry, then update it to avoid dupes
- if (string.Equals(person.Type, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
- {
- var existing = People.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase));
-
- if (existing != null)
- {
- existing.Type = PersonType.GuestStar;
- existing.SortOrder = person.SortOrder ?? existing.SortOrder;
- return;
- }
- }
-
- if (string.Equals(person.Type, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
- {
- // If the actor already exists without a role and we have one, fill it in
- var existing = People.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && (p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase) || p.Type.Equals(PersonType.GuestStar, StringComparison.OrdinalIgnoreCase)));
- if (existing == null)
- {
- // Wasn't there - add it
- People.Add(person);
- }
- else
- {
- // Was there, if no role and we have one - fill it in
- if (string.IsNullOrWhiteSpace(existing.Role) && !string.IsNullOrWhiteSpace(person.Role))
- {
- existing.Role = person.Role;
- }
-
- existing.SortOrder = person.SortOrder ?? existing.SortOrder;
- }
- }
- else
- {
- var existing = People.FirstOrDefault(p =>
- string.Equals(p.Name, person.Name, StringComparison.OrdinalIgnoreCase) &&
- string.Equals(p.Type, person.Type, StringComparison.OrdinalIgnoreCase));
-
- // Check for dupes based on the combination of Name and Type
- if (existing == null)
- {
- People.Add(person);
- }
- else
- {
- existing.SortOrder = person.SortOrder ?? existing.SortOrder;
- }
- }
+ PeopleHelper.AddPerson(People, person);
}
///
diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs
new file mode 100644
index 000000000..3468ca2d5
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs
@@ -0,0 +1,100 @@
+using MediaBrowser.Model.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace MediaBrowser.Controller.Entities
+{
+ public static class PeopleHelper
+ {
+ public static void AddPerson(List people, PersonInfo person)
+ {
+ if (person == null)
+ {
+ throw new ArgumentNullException("person");
+ }
+
+ if (string.IsNullOrWhiteSpace(person.Name))
+ {
+ throw new ArgumentNullException();
+ }
+
+ // Normalize
+ if (string.Equals(person.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
+ {
+ person.Type = PersonType.GuestStar;
+ }
+ else if (string.Equals(person.Role, PersonType.Director, StringComparison.OrdinalIgnoreCase))
+ {
+ person.Type = PersonType.Director;
+ }
+ else if (string.Equals(person.Role, PersonType.Producer, StringComparison.OrdinalIgnoreCase))
+ {
+ person.Type = PersonType.Producer;
+ }
+ else if (string.Equals(person.Role, PersonType.Writer, StringComparison.OrdinalIgnoreCase))
+ {
+ person.Type = PersonType.Writer;
+ }
+
+ // If the type is GuestStar and there's already an Actor entry, then update it to avoid dupes
+ if (string.Equals(person.Type, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
+ {
+ var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase));
+
+ if (existing != null)
+ {
+ existing.Type = PersonType.GuestStar;
+ existing.SortOrder = person.SortOrder ?? existing.SortOrder;
+ return;
+ }
+ }
+
+ if (string.Equals(person.Type, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
+ {
+ // If the actor already exists without a role and we have one, fill it in
+ var existing = people.FirstOrDefault(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && (p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase) || p.Type.Equals(PersonType.GuestStar, StringComparison.OrdinalIgnoreCase)));
+ if (existing == null)
+ {
+ // Wasn't there - add it
+ people.Add(person);
+ }
+ else
+ {
+ // Was there, if no role and we have one - fill it in
+ if (string.IsNullOrWhiteSpace(existing.Role) && !string.IsNullOrWhiteSpace(person.Role))
+ {
+ existing.Role = person.Role;
+ }
+
+ existing.SortOrder = person.SortOrder ?? existing.SortOrder;
+ }
+ }
+ else
+ {
+ var existing = people.FirstOrDefault(p =>
+ string.Equals(p.Name, person.Name, StringComparison.OrdinalIgnoreCase) &&
+ string.Equals(p.Type, person.Type, StringComparison.OrdinalIgnoreCase));
+
+ // Check for dupes based on the combination of Name and Type
+ if (existing == null)
+ {
+ people.Add(person);
+ }
+ else
+ {
+ existing.SortOrder = person.SortOrder ?? existing.SortOrder;
+ }
+ }
+ }
+
+ public static bool ContainsPerson(List people, string name)
+ {
+ if (string.IsNullOrWhiteSpace(name))
+ {
+ throw new ArgumentNullException("name");
+ }
+ return people.Any(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs
index ef24d4347..bbd112de0 100644
--- a/MediaBrowser.Controller/Entities/Person.cs
+++ b/MediaBrowser.Controller/Entities/Person.cs
@@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.Entities
public Func GetItemFilter()
{
- return i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase));
+ return i => LibraryManager.GetPeople(i).Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase));
}
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index bf86c049f..62578e675 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -173,6 +173,7 @@
+
diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
index a8a3e88ab..2ed12973b 100644
--- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
+++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
@@ -490,7 +490,7 @@ namespace MediaBrowser.Controller.Providers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
break;
}
@@ -502,7 +502,7 @@ namespace MediaBrowser.Controller.Providers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
break;
}
@@ -527,7 +527,7 @@ namespace MediaBrowser.Controller.Providers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
}
break;
@@ -541,7 +541,7 @@ namespace MediaBrowser.Controller.Providers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
break;
}
@@ -1154,7 +1154,7 @@ namespace MediaBrowser.Controller.Providers
{
continue;
}
- item.AddPerson(person);
+ PeopleHelper.AddPerson(item.People, person);
}
}
break;
diff --git a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs
index 736d3e984..6771fd1ab 100644
--- a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs
+++ b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs
@@ -488,7 +488,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
private async Task> GetItemsFromPerson(Person person, User user, int? startIndex, int? limit)
{
- var items = user.RootFolder.GetRecursiveChildren(user, i => i is Movie || i is Series && i.ContainsPerson(person.Name))
+ var items = user.RootFolder.GetRecursiveChildren(user, i => i is Movie || i is Series && PeopleHelper.ContainsPerson(_libraryManager.GetPeople(i), person.Name))
.ToList();
var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
@@ -503,7 +503,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
.ToList();
var trailersToAdd = trailerResult.Items
- .Where(i => i.ContainsPerson(person.Name))
+ .Where(i => PeopleHelper.ContainsPerson(_libraryManager.GetPeople(i), person.Name))
.Where(i =>
{
// Try to filter out dupes using imdb id
@@ -569,7 +569,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
private bool EnablePeopleDisplay(BaseItem item)
{
- if (item.People.Count > 0)
+ if (_libraryManager.GetPeople(item).Count > 0)
{
return item is Movie;
}
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
index 33f35450d..25ca792ac 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
@@ -134,7 +134,7 @@ namespace MediaBrowser.Providers.MediaInfo
foreach (var person in data.People)
{
- audio.AddPerson(new PersonInfo
+ PeopleHelper.AddPerson(audio.People, new PersonInfo
{
Name = person.Name,
Type = person.Type,
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
index e1ee6ac5a..f141fbd59 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
@@ -378,7 +378,7 @@ namespace MediaBrowser.Providers.MediaInfo
foreach (var person in data.People)
{
- video.AddPerson(new PersonInfo
+ PeopleHelper.AddPerson(video.People, new PersonInfo
{
Name = person.Name,
Type = person.Type,
diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs
index c23ed3786..dcf19f0d0 100644
--- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs
+++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs
@@ -233,13 +233,19 @@ namespace MediaBrowser.Providers.Movies
//actors come from cast
if (movieData.casts != null && movieData.casts.cast != null)
{
- foreach (var actor in movieData.casts.cast.OrderBy(a => a.order)) movie.AddPerson(new PersonInfo { Name = actor.name.Trim(), Role = actor.character, Type = PersonType.Actor, SortOrder = actor.order });
+ foreach (var actor in movieData.casts.cast.OrderBy(a => a.order))
+ {
+ PeopleHelper.AddPerson(movie.People, new PersonInfo { Name = actor.name.Trim(), Role = actor.character, Type = PersonType.Actor, SortOrder = actor.order });
+ }
}
//and the rest from crew
if (movieData.casts != null && movieData.casts.crew != null)
{
- foreach (var person in movieData.casts.crew) movie.AddPerson(new PersonInfo { Name = person.name.Trim(), Role = person.job, Type = person.department });
+ foreach (var person in movieData.casts.crew)
+ {
+ PeopleHelper.AddPerson(movie.People, new PersonInfo { Name = person.name.Trim(), Role = person.job, Type = person.department });
+ }
}
if (movieData.keywords != null && movieData.keywords.keywords != null)
diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs
index 68601b6b2..db5bc3b65 100644
--- a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs
@@ -603,7 +603,7 @@ namespace MediaBrowser.Providers.TV
.Where(i => !string.IsNullOrWhiteSpace(i))
.Select(str => new PersonInfo { Type = personType, Name = str.Trim() }))
{
- item.AddPerson(person);
+ PeopleHelper.AddPerson(item.People, person);
}
}
@@ -631,7 +631,7 @@ namespace MediaBrowser.Providers.TV
{
if (!string.IsNullOrWhiteSpace(person.Name))
{
- item.AddPerson(person);
+ PeopleHelper.AddPerson(item.People, person);
}
}
}
diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
index 8bdd914df..e7ac830d1 100644
--- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
@@ -719,7 +719,7 @@ namespace MediaBrowser.Providers.TV
if (!string.IsNullOrWhiteSpace(personInfo.Name))
{
- series.AddPerson(personInfo);
+ PeopleHelper.AddPerson(series.People, personInfo);
}
}
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
index 6a0e1208a..0cd4b0a5c 100644
--- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
+++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
@@ -1237,7 +1237,6 @@ namespace MediaBrowser.Server.Implementations.Channels
item.Overview = info.Overview;
item.IndexNumber = info.IndexNumber;
item.ParentIndexNumber = info.ParentIndexNumber;
- item.People = info.People;
item.PremiereDate = info.PremiereDate;
item.ProductionYear = info.ProductionYear;
item.ProviderIds = info.ProviderIds;
@@ -1277,6 +1276,8 @@ namespace MediaBrowser.Server.Implementations.Channels
{
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
_libraryManager.RegisterItem(item);
+
+ await _libraryManager.UpdatePeople(item, info.People ?? new List()).ConfigureAwait(false);
}
return item;
diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
index 868c667f6..c99cf29e8 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
@@ -573,7 +573,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
break;
}
@@ -592,7 +592,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
}
break;
@@ -606,7 +606,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
continue;
}
- item.AddPerson(p);
+ PeopleHelper.AddPerson(item.People, p);
}
break;
}
@@ -617,7 +617,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
var person = GetPersonFromXmlNode(subtree);
- item.AddPerson(person);
+ PeopleHelper.AddPerson(item.People, person);
}
break;
}