From 055a851e2793e4feb2ba652814f2d76242dfbd76 Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Sun, 26 Jun 2022 22:54:47 -0500
Subject: [PATCH 1/2] Allow customizing analysis settings
---
.../Configuration/PluginConfiguration.cs | 14 ++++++
.../Configuration/configPage.html | 45 +++++++++++++++++++
.../QueueManager.cs | 23 ++++++++--
README.md | 1 +
4 files changed, 80 insertions(+), 3 deletions(-)
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
+
+
+
+
+
+
+ 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.
+
@@ -480,6 +495,7 @@
document.querySelector('#AnalysisPercent').value = config.AnalysisPercent;
document.querySelector('#AnalysisLengthLimit').value = config.AnalysisLengthLimit;
+ document.querySelector('#MinimumDuration').value = config.MinimumIntroDuration;
document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints;
document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment;
@@ -498,6 +514,7 @@
config.AnalysisPercent = document.querySelector('#AnalysisPercent').value;
config.AnalysisLengthLimit = document.querySelector('#AnalysisLengthLimit').value;
+ config.MinimumIntroDuration = document.querySelector('#MinimumDuration').value;
config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked;
config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value;
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs
index 5946a62..c8f371c 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs
@@ -48,12 +48,13 @@ public class QueueManager
var config = Plugin.Instance!.Configuration;
analysisPercent = Convert.ToDouble(config.AnalysisPercent) / 100;
- if (config.AnalysisLengthLimit != 10 || config.AnalysisPercent != 25)
+ if (config.AnalysisLengthLimit != 10 || config.AnalysisPercent != 25 || config.MinimumIntroDuration != 15)
{
_logger.LogDebug(
- "Introduction scan is limited to the first {Percent}% or the first {Minutes} minutes of each episode (whichever is smaller)",
+ "Analysis settings have been changed to: {Percent}%/{Minutes}m and a minimum of {Minimum}s",
config.AnalysisPercent,
- config.AnalysisLengthLimit);
+ config.AnalysisLengthLimit,
+ config.MinimumIntroDuration);
}
// For all TV show libraries, enqueue all contained items.
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs
index 0520f20..20e5e2f 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs
@@ -15,11 +15,6 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper;
///
public class FingerprinterTask : IScheduledTask
{
- ///
- /// Minimum time (in seconds) for a contiguous time range to be considered an introduction.
- ///
- private const int MinimumIntroDuration = 15;
-
///
/// Maximum number of bits (out of 32 total) that can be different between segments before they are considered dissimilar.
/// 6 bits means the audio must be at least 81% similar (1 - 6 / 32).
@@ -68,6 +63,11 @@ public class FingerprinterTask : IScheduledTask
///
private Dictionary> _fingerprintCache;
+ ///
+ /// Minimum duration of similar audio that will be considered an introduction.
+ ///
+ private static int minimumIntroDuration = 15;
+
///
/// Initializes a new instance of the class.
///
@@ -143,6 +143,8 @@ public class FingerprinterTask : IScheduledTask
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
};
+ minimumIntroDuration = Plugin.Instance!.Configuration.MinimumIntroDuration;
+
Parallel.ForEach(queue, options, (season) =>
{
var first = season.Value[0];
@@ -533,7 +535,7 @@ public class FingerprinterTask : IScheduledTask
// Now that both fingerprints have been compared at this shift, see if there's a contiguous time range.
var lContiguous = TimeRangeHelpers.FindContiguous(lhsTimes.ToArray(), MaximumDistance);
- if (lContiguous is null || lContiguous.Duration < MinimumIntroDuration)
+ if (lContiguous is null || lContiguous.Duration < minimumIntroDuration)
{
return (new TimeRange(), new TimeRange());
}
@@ -599,7 +601,7 @@ public class FingerprinterTask : IScheduledTask
var id = episode.EpisodeId;
var duration = GetIntroDuration(id);
- if (duration < MinimumIntroDuration)
+ if (duration < minimumIntroDuration)
{
continue;
}