diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs index 5a31357..d1854c7 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs @@ -14,6 +14,8 @@ public class PluginConfiguration : BasePluginConfiguration { } + // ===== Analysis settings ===== + /// /// Gets or sets a value indicating whether the episode's fingerprint should be cached to the filesystem. /// @@ -24,6 +26,18 @@ public class PluginConfiguration : BasePluginConfiguration /// public int MaxParallelism { get; set; } = 2; + /// + /// Gets or sets the percentage of each episode's audio track to analyze. + /// + public int AnalysisPercent { get; set; } = 25; + + /// + /// Gets or sets the upper limit (in minutes) on the length of each episode's audio track that will be analyzed. + /// + public int AnalysisLengthLimit { get; set; } = 10; + + // ===== Playback settings ===== + /// /// Gets or sets a value indicating whether introductions should be automatically skipped. /// diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index 54d8930..3531b2d 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -37,6 +37,45 @@ Maximum degree of parallelism to use when analyzing episodes. + +
+ Modify introduction requirements + +
+ + +
+ Analysis will be limited to this percentage of each episode's audio. For example, a + value of 25 (the default) will limit analysis to the first quarter of each episode. +
+
+ +
+ + +
+ Analysis will be limited to this amount of each episode's audio. For example, a + value of 10 (the default) will limit analysis to the first 10 minutes of each + episode. +
+
+ +

+ The amount of each episode's audio that will be analyzed is determined by these two + settings. The minimum of (episode duration * percent, maximum runtime) is the amount of + audio that will be analyzed.
+ + If these settings are changed after analyzing your media, the cached fingerprints and + introduction timestamps for each season you want to analyze with the modified settings + will have to be deleted. +

+ + Increasing these settings will cause episode analysis to take much longer. +
@@ -439,6 +478,9 @@ document.querySelector('#AutoSkip').checked = config.AutoSkip; document.querySelector('#MaxParallelism').value = config.MaxParallelism; + document.querySelector('#AnalysisPercent').value = config.AnalysisPercent; + document.querySelector('#AnalysisLengthLimit').value = config.AnalysisLengthLimit; + document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints; document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment; document.querySelector('#HidePromptAdjustment').value = config.HidePromptAdjustment; @@ -454,6 +496,9 @@ config.AutoSkip = document.querySelector('#AutoSkip').checked; config.MaxParallelism = document.querySelector('#MaxParallelism').value; + config.AnalysisPercent = document.querySelector('#AnalysisPercent').value; + config.AnalysisLengthLimit = document.querySelector('#AnalysisLengthLimit').value; + config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked; config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value; config.HidePromptAdjustment = document.querySelector("#HidePromptAdjustment").value; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs index 3996fbc..5946a62 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs @@ -17,6 +17,8 @@ public class QueueManager private ILibraryManager _libraryManager; private ILogger _logger; + private double analysisPercent; + /// /// Initializes a new instance of the class. /// @@ -42,6 +44,18 @@ public class QueueManager Plugin.Instance!.AnalysisQueue.Clear(); + // If analysis settings have been changed from the default, log the modified settings. + var config = Plugin.Instance!.Configuration; + analysisPercent = Convert.ToDouble(config.AnalysisPercent) / 100; + + if (config.AnalysisLengthLimit != 10 || config.AnalysisPercent != 25) + { + _logger.LogDebug( + "Introduction scan is limited to the first {Percent}% or the first {Minutes} minutes of each episode (whichever is smaller)", + config.AnalysisPercent, + config.AnalysisLengthLimit); + } + // For all TV show libraries, enqueue all contained items. foreach (var folder in _libraryManager.GetVirtualFolders()) { @@ -132,14 +146,17 @@ public class QueueManager Plugin.Instance.AnalysisQueue[episode.SeasonId] = new List(); } - // Only fingerprint up to 25% of the episode and at most 10 minutes. + var config = Plugin.Instance!.Configuration; + + // 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; if (duration >= 5 * 60) { - duration /= 4; + duration *= analysisPercent; } - duration = Math.Min(duration, 10 * 60); + duration = Math.Min(duration, 60 * config.AnalysisLengthLimit); Plugin.Instance.AnalysisQueue[episode.SeasonId].Add(new QueuedEpisode() { diff --git a/README.md b/README.md index 877beba..29ebe30 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Plugin versions v0.1.0 and older require `fpcalc` to be installed. Show introductions will only be detected if they are: * Located within the first 25% of an episode, or the first 10 minutes, whichever is smaller + * Both of these settings are customizable * At least 20 seconds long ## Step 1: Optional: use the modified web interface