Skip to content

Commit

Permalink
Ensure no duplicate Ids are permitted. (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlauuzo committed May 8, 2024
1 parent d1a4cac commit b1e17b1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ public void QueueEpisode(Episode episode)
return;
}

// Allocate a new list for each new season
_queuedEpisodes.TryAdd(episode.SeasonId, new List<QueuedEpisode>());

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;
Expand All @@ -214,9 +227,6 @@ public void QueueEpisode(Episode episode)
fingerprintDuration,
60 * Plugin.Instance!.Configuration.AnalysisLengthLimit);

// Allocate a new list for each new season
_queuedEpisodes.TryAdd(episode.SeasonId, new List<QueuedEpisode>());

// Queue the episode for analysis
var maxCreditsDuration = Plugin.Instance!.Configuration.MaximumCreditsDuration;
_queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode()
Expand Down

0 comments on commit b1e17b1

Please sign in to comment.