diff --git a/Kyoo.Common/Models/Collection.cs b/Kyoo.Common/Models/Collection.cs index ea4430d1..ca1cf29c 100644 --- a/Kyoo.Common/Models/Collection.cs +++ b/Kyoo.Common/Models/Collection.cs @@ -48,7 +48,7 @@ namespace Kyoo.Models Overview = collection.Overview; if (ImgPrimary == null) ImgPrimary = collection.ImgPrimary; - Shows = Shows == null ? collection.Shows : Shows.Concat(collection.Shows); + Shows = Utility.MergeLists(Shows, collection.Shows, (x, y) => x.Slug == y.Slug); return this; } } diff --git a/Kyoo.Common/Models/Show.cs b/Kyoo.Common/Models/Show.cs index ff264bb9..28c31eaa 100644 --- a/Kyoo.Common/Models/Show.cs +++ b/Kyoo.Common/Models/Show.cs @@ -109,8 +109,8 @@ namespace Kyoo.Models ID = other.ID; Slug ??= other.Slug; Title ??= other.Title; - Aliases = Aliases == null ? other.Aliases : Aliases.Concat(other.Aliases).ToArray(); - Genres = Genres == null ? other.Genres : Genres.Concat(other.Genres); + Aliases = Utility.MergeLists(Aliases, other.Aliases).ToArray(); + Genres = Utility.MergeLists(Genres, other.Genres, (x, y) => x.Slug == y.Slug); Path ??= other.Path; Overview ??= other.Overview; TrailerUrl ??= other.TrailerUrl; @@ -121,6 +121,8 @@ namespace Kyoo.Models ImgThumb ??= other.ImgThumb; ImgLogo ??= other.ImgLogo; ImgBackdrop ??= other.ImgBackdrop; + if (other.Studio != null) + Studio ??= other.Studio; ExternalIDs = string.Join('|', ExternalIDs, other.ExternalIDs); return this; } diff --git a/Kyoo.Common/Utility.cs b/Kyoo.Common/Utility.cs index 8e1e290f..9cabbd5a 100644 --- a/Kyoo.Common/Utility.cs +++ b/Kyoo.Common/Utility.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; using Kyoo.Models; @@ -58,5 +62,17 @@ namespace Kyoo break; } } + + public static IEnumerable MergeLists(IEnumerable first, IEnumerable second, Func isEqual = null) + { + if (first == null) + return second; + if (second == null) + return first; + List list = first.ToList(); + if (isEqual == null) + isEqual = (x, y) => x.Equals(y); + return list.Concat(second.Where(x => !list.Any(y => isEqual(x, y)))); + } } } \ No newline at end of file diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 86d6bde7..947871b7 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -16,6 +16,10 @@ Kyoo.Program + + bin/Release/ + +