aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/PeopleHelper.cs
diff options
context:
space:
mode:
authorstefan <stefan@hegedues.at>2018-09-12 19:26:21 +0200
committerstefan <stefan@hegedues.at>2018-09-12 19:26:21 +0200
commit48facb797ed912e4ea6b04b17d1ff190ac2daac4 (patch)
tree8dae77a31670a888d733484cb17dd4077d5444e8 /MediaBrowser.Controller/Entities/PeopleHelper.cs
parentc32d8656382a0eacb301692e0084377fc433ae9b (diff)
Update to 3.5.2 and .net core 2.1
Diffstat (limited to 'MediaBrowser.Controller/Entities/PeopleHelper.cs')
-rw-r--r--MediaBrowser.Controller/Entities/PeopleHelper.cs119
1 files changed, 0 insertions, 119 deletions
diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs
deleted file mode 100644
index 412eb9499..000000000
--- a/MediaBrowser.Controller/Entities/PeopleHelper.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-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<PersonInfo> 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;
- MergeExisting(existing, person);
- 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;
- }
-
- MergeExisting(existing, person);
- }
- }
- 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
- {
- MergeExisting(existing, person);
- }
- }
- }
-
- private static void MergeExisting(PersonInfo existing, PersonInfo person)
- {
- existing.SortOrder = person.SortOrder ?? existing.SortOrder;
- existing.ImageUrl = person.ImageUrl ?? existing.ImageUrl;
-
- foreach (var id in person.ProviderIds)
- {
- existing.SetProviderId(id.Key, id.Value);
- }
- }
-
- public static bool ContainsPerson(List<PersonInfo> people, string name)
- {
- if (string.IsNullOrWhiteSpace(name))
- {
- throw new ArgumentNullException("name");
- }
-
- foreach (var i in people)
- {
- if (string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- }
- return false;
- }
- }
-}