From cfba1ed39b3788eecaadf3577204da774a6baece Mon Sep 17 00:00:00 2001 From: rlauuzo <46294892+rlauuzo@users.noreply.github.com> Date: Wed, 8 May 2024 14:36:14 +0200 Subject: [PATCH] Ensure no duplicate Ids are permitted. (#147) --- .../QueueManager.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs index a462fd7..2c1d1ac 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs @@ -200,6 +200,19 @@ public class QueueManager return; } + // Allocate a new list for each new season + _queuedEpisodes.TryAdd(episode.SeasonId, new List()); + + if (_queuedEpisodes[episode.SeasonId].Any(e => e.EpisodeId == episode.Id)) + { + _logger.LogDebug( + "\"{Name}\" from series \"{Series}\" ({Id}) is already queued", + episode.Name, + episode.SeriesName, + episode.Id); + return; + } + // Limit analysis to the first X% of the episode and at most Y minutes. // X and Y default to 25% and 10 minutes. var duration = TimeSpan.FromTicks(episode.RunTimeTicks ?? 0).TotalSeconds; @@ -214,9 +227,6 @@ public class QueueManager fingerprintDuration, 60 * Plugin.Instance!.Configuration.AnalysisLengthLimit); - // Allocate a new list for each new season - _queuedEpisodes.TryAdd(episode.SeasonId, new List()); - // Queue the episode for analysis var maxCreditsDuration = Plugin.Instance!.Configuration.MaximumCreditsDuration; _queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode()