Fix dup Actor node in xml and add role consolidation
This commit is contained in:
parent
3a3932bfbb
commit
449cb05f7b
|
@ -1169,11 +1169,18 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
if (string.Equals(person.Type, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(person.Type, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Only add actors if there isn't an existing one of type Actor or GuestStar
|
// If the actor already exists without a role and we have one, fill it in
|
||||||
if (!People.Any(p => p.Name.Equals(person.Name, StringComparison.OrdinalIgnoreCase) && (p.Type.Equals(PersonType.Actor, StringComparison.OrdinalIgnoreCase) || p.Type.Equals(PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))))
|
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);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
@ -281,13 +282,26 @@ namespace MediaBrowser.Controller.Providers
|
||||||
|
|
||||||
case "Actors":
|
case "Actors":
|
||||||
{
|
{
|
||||||
foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor }))
|
|
||||||
|
var actors = reader.ReadInnerXml();
|
||||||
|
|
||||||
|
if (actors.Contains("<"))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(p.Name))
|
// This is one of the mis-named "Actors" full nodes created by MB2
|
||||||
|
// Create a reader and pass it to the persons node processor
|
||||||
|
FetchDataFromPersonsNode(new XmlTextReader(new StringReader("<Persons>" + actors + "</Persons>")), item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Old-style piped string
|
||||||
|
foreach (var p in SplitNames(actors).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor }))
|
||||||
{
|
{
|
||||||
continue;
|
if (string.IsNullOrWhiteSpace(p.Name))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
item.AddPerson(p);
|
||||||
}
|
}
|
||||||
item.AddPerson(p);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -500,6 +514,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
switch (reader.Name)
|
switch (reader.Name)
|
||||||
{
|
{
|
||||||
case "Person":
|
case "Person":
|
||||||
|
case "Actor":
|
||||||
{
|
{
|
||||||
foreach (var person in GetPersonsFromXmlNode(reader.ReadSubtree()))
|
foreach (var person in GetPersonsFromXmlNode(reader.ReadSubtree()))
|
||||||
{
|
{
|
||||||
|
@ -619,7 +634,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
private IEnumerable<PersonInfo> GetPersonsFromXmlNode(XmlReader reader)
|
private IEnumerable<PersonInfo> GetPersonsFromXmlNode(XmlReader reader)
|
||||||
{
|
{
|
||||||
var names = new List<string>();
|
var names = new List<string>();
|
||||||
var type = string.Empty;
|
var type = "Actor"; // If type is not specified assume actor
|
||||||
var role = string.Empty;
|
var role = string.Empty;
|
||||||
|
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
|
@ -173,7 +173,4 @@ Global
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(Performance) = preSolution
|
|
||||||
HasPerformanceSessions = true
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user