From ffdb08cfe655a5357666d18d3dc6b9f0b668434b Mon Sep 17 00:00:00 2001
From: Bogdan <mynameisbogdan@users.noreply.github.com>
Date: Sun, 11 Aug 2024 14:40:21 +0300
Subject: [PATCH] Fixed: Dedupe titles to avoid similar search requests

---
 .../DataAugmentation/Scene/SceneMappingService.cs           | 4 +++-
 src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs     | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs
index 94e30fec0..10aac05ec 100644
--- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs
+++ b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs
@@ -63,7 +63,9 @@ namespace NzbDrone.Core.DataAugmentation.Scene
                                             sceneSeasonNumbers.Contains(n.SceneSeasonNumber ?? -1) ||
                                             ((n.SeasonNumber ?? -1) == -1 && (n.SceneSeasonNumber ?? -1) == -1 && n.SceneOrigin != "tvdb"))
                                 .Where(n => IsEnglish(n.SearchTerm))
-                                .Select(n => n.SearchTerm).Distinct().ToList();
+                                .Select(n => n.SearchTerm)
+                                .Distinct(StringComparer.InvariantCultureIgnoreCase)
+                                .ToList();
 
             return names;
         }
diff --git a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs
index ee892b7b9..10b9fc0fb 100644
--- a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs
+++ b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs
@@ -193,7 +193,7 @@ namespace NzbDrone.Core.IndexerSearch
             foreach (var item in dict)
             {
                 item.Value.Episodes = item.Value.Episodes.Distinct().ToList();
-                item.Value.SceneTitles = item.Value.SceneTitles.Distinct().ToList();
+                item.Value.SceneTitles = item.Value.SceneTitles.Distinct(StringComparer.InvariantCultureIgnoreCase).ToList();
             }
 
             return dict.Values.ToList();
@@ -221,7 +221,7 @@ namespace NzbDrone.Core.IndexerSearch
 
             foreach (var item in dict)
             {
-                item.Value.SceneTitles = item.Value.SceneTitles.Distinct().ToList();
+                item.Value.SceneTitles = item.Value.SceneTitles.Distinct(StringComparer.InvariantCultureIgnoreCase).ToList();
             }
 
             return dict.Values.ToList();
@@ -463,7 +463,7 @@ namespace NzbDrone.Core.IndexerSearch
             spec.UserInvokedSearch = userInvokedSearch;
             spec.InteractiveSearch = interactiveSearch;
 
-            if (!spec.SceneTitles.Contains(series.Title))
+            if (!spec.SceneTitles.Contains(series.Title, StringComparer.InvariantCultureIgnoreCase))
             {
                 spec.SceneTitles.Add(series.Title);
             }