From 57249bfe87afcfd4d9e5b8a3bf80e69573c269aa Mon Sep 17 00:00:00 2001 From: rlauuzo <46294892+rlauuzo@users.noreply.github.com> Date: Fri, 10 May 2024 14:05:59 +0200 Subject: [PATCH] change chromaprint offset, reorder analyzers, improve prompt timing (#153) --- .../Analyzers/BlackFrameAnalyzer.cs | 2 +- .../Analyzers/ChromaprintAnalyzer.cs | 2 +- .../Configuration/configPage.html | 16 ++++++++-------- .../Controllers/SkipIntroController.cs | 12 ++++++------ .../ScheduledTasks/BaseItemAnalyzerTask.cs | 10 +++++----- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs index d797cf4..b2e3e5b 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs @@ -167,7 +167,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer if (frames.Length == 0) { // Since no black frames were found, slide the range closer to the end - start = midpoint; + start = midpoint - TimeSpan.FromSeconds(2); if (midpoint - TimeSpan.FromSeconds(lowerLimit) < _maximumError) { diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs index 6e2ee7b..f4bb2d7 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs @@ -16,7 +16,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer /// Seconds of audio in one fingerprint point. /// This value is defined by the Chromaprint library and should not be changed. /// - private const double SamplesToSeconds = 0.128; + private const double SamplesToSeconds = 0.1238; private int minimumIntroDuration; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index 404d168..51bb9aa 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -555,14 +555,14 @@ Up arrow - Shift the left episode up by 0.128 seconds. + Shift the left episode up by 0.1238 seconds. Holding control will shift the episode by 10 seconds. Down arrow - Shift the left episode down by 0.128 seconds. + Shift the left episode down by 0.1238 seconds. Holding control will shift the episode by 10 seconds. @@ -957,13 +957,13 @@ case "ArrowDown": if (timestampError.value != "") { // if the control key is pressed, shift LHS by 10s. Otherwise, shift by 1. - offsetDelta = e.ctrlKey ? 10 / 0.128 : 1; + offsetDelta = e.ctrlKey ? 10 / 0.1238 : 1; } break; case "ArrowUp": if (timestampError.value != "") { - offsetDelta = e.ctrlKey ? -10 / 0.128 : -1; + offsetDelta = e.ctrlKey ? -10 / 0.1238 : -1; } break; @@ -1147,12 +1147,12 @@ let lTime, rTime, diffPos; if (shift < 0) { - lTime = y * 0.128; - rTime = (y + shift) * 0.128; + lTime = y * 0.1238; + rTime = (y + shift) * 0.1238; diffPos = y + shift; } else { - lTime = (y - shift) * 0.128; - rTime = y * 0.128; + lTime = (y - shift) * 0.1238; + rTime = y * 0.1238; diffPos = y - shift; } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs index 4b59efa..2023b79 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs @@ -90,15 +90,15 @@ public class SkipIntroController : ControllerBase segment.IntroEnd -= config.SecondsOfIntroToPlay; if (config.PersistSkipButton) { - segment.ShowSkipPromptAt = segment.IntroStart; - segment.HideSkipPromptAt = segment.IntroEnd; + segment.ShowSkipPromptAt = segment.IntroStart; + segment.HideSkipPromptAt = segment.IntroEnd - 1; } else { - segment.ShowSkipPromptAt = Math.Max(0, segment.IntroStart - config.ShowPromptAdjustment); - segment.HideSkipPromptAt = Math.Min( - segment.IntroStart + config.HidePromptAdjustment, - segment.IntroEnd); + segment.ShowSkipPromptAt = Math.Max(0, segment.IntroStart - config.ShowPromptAdjustment); + segment.HideSkipPromptAt = Math.Min( + segment.IntroStart + config.HidePromptAdjustment, + segment.IntroEnd - 1); } return segment; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs index c0cbbb1..c29c544 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs @@ -218,16 +218,16 @@ public class BaseItemAnalyzerTask var analyzers = new Collection(); analyzers.Add(new ChapterAnalyzer(_loggerFactory.CreateLogger())); - if (Plugin.Instance!.Configuration.UseChromaprint) - { - analyzers.Add(new ChromaprintAnalyzer(_loggerFactory.CreateLogger())); - } - if (mode == AnalysisMode.Credits) { analyzers.Add(new BlackFrameAnalyzer(_loggerFactory.CreateLogger())); } + if (Plugin.Instance!.Configuration.UseChromaprint) + { + analyzers.Add(new ChromaprintAnalyzer(_loggerFactory.CreateLogger())); + } + // Use each analyzer to find skippable ranges in all media files, removing successfully // analyzed items from the queue. foreach (var analyzer in analyzers)