/// <summary> /// Gets the album similarity score. /// </summary> /// <param name="item1">The item1.</param> /// <param name="item1People">The item1 people.</param> /// <param name="allPeople">All people.</param> /// <param name="item2">The item2.</param> /// <returns>System.Int32.</returns> private int GetAlbumSimilarityScore(BaseItem item1, List <PersonInfo> item1People, List <PersonInfo> allPeople, BaseItem item2) { var points = SimilarItemsHelper.GetSimiliarityScore(item1, item1People, allPeople, item2); var album1 = (MusicAlbum)item1; var album2 = (MusicAlbum)item2; var artists1 = album1 .GetAllArtists() .DistinctNames() .ToList(); var artists2 = new HashSet <string>( album2.GetAllArtists().DistinctNames(), StringComparer.OrdinalIgnoreCase); return(points + artists1.Where(artists2.Contains).Sum(i => 5)); }
/// <summary> /// Gets the album similarity score. /// </summary> /// <param name="item1">The item1.</param> /// <param name="item2">The item2.</param> /// <returns>System.Int32.</returns> private int GetAlbumSimilarityScore(BaseItem item1, BaseItem item2) { var points = SimilarItemsHelper.GetSimiliarityScore(item1, item2); var album1 = (MusicAlbum)item1; var album2 = (MusicAlbum)item2; var artists1 = album1 .AllArtists .DistinctNames() .ToList(); var artists2 = album2 .AllArtists .DistinctNames() .ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); return(points + artists1.Where(artists2.ContainsKey).Sum(i => 5)); }
/// <summary> /// Gets the album similarity score. /// </summary> /// <param name="item1">The item1.</param> /// <param name="item2">The item2.</param> /// <returns>System.Int32.</returns> private int GetAlbumSimilarityScore(BaseItem item1, BaseItem item2) { var points = SimilarItemsHelper.GetSimiliarityScore(item1, item2); var album1 = (MusicAlbum)item1; var album2 = (MusicAlbum)item2; var artists1 = album1.GetRecursiveChildren() .OfType <Audio>() .SelectMany(i => { var list = new List <string>(); if (!string.IsNullOrEmpty(i.AlbumArtist)) { list.Add(i.AlbumArtist); } list.AddRange(i.Artists); return(list); }) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); var artists2 = album2.GetRecursiveChildren() .OfType <Audio>() .SelectMany(i => { var list = new List <string>(); if (!string.IsNullOrEmpty(i.AlbumArtist)) { list.Add(i.AlbumArtist); } list.AddRange(i.Artists); return(list); }) .Distinct(StringComparer.OrdinalIgnoreCase) .ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); return(points + artists1.Where(artists2.ContainsKey).Sum(i => 5)); }
/// <summary> /// Gets the album similarity score. /// </summary> /// <param name="item1">The item1.</param> /// <param name="item2">The item2.</param> /// <returns>System.Int32.</returns> private int GetAlbumSimilarityScore(BaseItem item1, BaseItem item2) { var points = SimilarItemsHelper.GetSimiliarityScore(item1, item2); var album1 = (MusicAlbum)item1; var album2 = (MusicAlbum)item2; var artists1 = album1.GetRecursiveChildren(i => i is IHasArtist) .Cast <IHasArtist>() .SelectMany(i => i.AllArtists) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); var artists2 = album2.GetRecursiveChildren(i => i is IHasArtist) .Cast <IHasArtist>() .SelectMany(i => i.AllArtists) .Distinct(StringComparer.OrdinalIgnoreCase) .ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); return(points + artists1.Where(artists2.ContainsKey).Sum(i => 5)); }