diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs index 46a6b0a..c7bf6a6 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs @@ -191,6 +191,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; @@ -205,9 +218,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