From 84f76ba3de1cfddacd5bbb1ce8975d6dc1a66868 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 2 May 2017 08:53:41 -0400 Subject: [PATCH] update people handling during metadata refresh --- .../Manager/ProviderUtils.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.cs index 13c12c8ff..dfa80a180 100644 --- a/MediaBrowser.Providers/Manager/ProviderUtils.cs +++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs @@ -4,6 +4,8 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using System.Linq; +using MediaBrowser.Controller.Extensions; namespace MediaBrowser.Providers.Manager { @@ -122,6 +124,11 @@ namespace MediaBrowser.Providers.Manager if (replaceData || targetResult.People == null || targetResult.People.Count == 0) { targetResult.People = sourceResult.People; + + } + else if (targetResult.People != null && sourceResult.People != null) + { + MergePeople(sourceResult.People, targetResult.People); } } @@ -205,6 +212,31 @@ namespace MediaBrowser.Providers.Manager } } + private static void MergePeople(List source, List target) + { + foreach (var person in target) + { + var normalizedName = person.Name.RemoveDiacritics(); + var personInSource = source.FirstOrDefault(i => string.Equals(i.Name.RemoveDiacritics(), normalizedName, StringComparison.OrdinalIgnoreCase)); + + if (personInSource != null) + { + foreach (var providerId in personInSource.ProviderIds) + { + if (!person.ProviderIds.ContainsKey(providerId.Key)) + { + person.ProviderIds[providerId.Key] = providerId.Value; + } + } + + if (string.IsNullOrWhiteSpace(person.ImageUrl)) + { + person.ImageUrl = personInSource.ImageUrl; + } + } + } + } + public static void MergeMetadataSettings(BaseItem source, BaseItem target) {