diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs index 1c28c5f..ba2ee30 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs @@ -76,8 +76,10 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer /// Credits timestamp. public Intro? AnalyzeMediaFile(QueuedEpisode episode, AnalysisMode mode, int minimum) { - // Start by analyzing the last four minutes of the file. - var start = TimeSpan.FromMinutes(4); + var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration(); + + // Start by analyzing the last N minutes of the file. + var start = TimeSpan.FromSeconds(config.MaximumEpisodeCreditsDuration); var end = TimeSpan.Zero; var firstFrameTime = 0.0; @@ -100,7 +102,11 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer tr.End); var frames = FFmpegWrapper.DetectBlackFrames(episode, tr, minimum); - _logger.LogTrace("{Episode}, black frames: {Count}", episode.Name, frames.Length); + _logger.LogTrace( + "{Episode} at {Start} has {Count} black frames", + episode.Name, + tr.Start, + frames.Length); if (frames.Length == 0) { diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs index 73ec9aa..5accbb4 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; +using System.Linq; using System.Text.RegularExpressions; using System.Threading; using Microsoft.Extensions.Logging; @@ -31,7 +32,6 @@ public class ChapterAnalyzer : IMediaFileAnalyzer AnalysisMode mode, CancellationToken cancellationToken) { - var unsuccessful = new List(); var skippableRanges = new Dictionary(); var expression = mode == AnalysisMode.Introduction ? @@ -53,7 +53,6 @@ public class ChapterAnalyzer : IMediaFileAnalyzer if (skipRange is null) { - unsuccessful.Add(episode); continue; } @@ -62,7 +61,10 @@ public class ChapterAnalyzer : IMediaFileAnalyzer Plugin.Instance!.UpdateTimestamps(skippableRanges, mode); - return unsuccessful.AsReadOnly(); + return analysisQueue + .Where(x => !skippableRanges.ContainsKey(x.EpisodeId)) + .ToList() + .AsReadOnly(); } /// diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs index 0964258..bb65789 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs @@ -33,12 +33,12 @@ public class QueuedEpisode public string Name { get; set; } = string.Empty; /// - /// Gets or sets the timestamp (in seconds) to stop searching for an introduction. + /// Gets or sets the timestamp (in seconds) to stop searching for an introduction at. /// public int IntroFingerprintEnd { get; set; } /// - /// Gets or sets the timestamp (in seconds) to start looking for end credits. + /// Gets or sets the timestamp (in seconds) to start looking for end credits at. /// public int CreditsFingerprintStart { get; set; }