diff --git a/IntroSkipper/Analyzers/BlackFrameAnalyzer.cs b/IntroSkipper/Analyzers/BlackFrameAnalyzer.cs index 7f58516..f5ea273 100644 --- a/IntroSkipper/Analyzers/BlackFrameAnalyzer.cs +++ b/IntroSkipper/Analyzers/BlackFrameAnalyzer.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; using IntroSkipper.Configuration; using IntroSkipper.Data; using Microsoft.Extensions.Logging; @@ -26,7 +27,7 @@ public class BlackFrameAnalyzer(ILogger logger) : IMediaFile private readonly int _blackFrameMinimumPercentage = _config.BlackFrameMinimumPercentage; /// - public IReadOnlyList AnalyzeMediaFiles( + public async Task> AnalyzeMediaFiles( IReadOnlyList analysisQueue, AnalysisMode mode, CancellationToken cancellationToken) @@ -46,7 +47,7 @@ public class BlackFrameAnalyzer(ILogger logger) : IMediaFile var searchDistance = 2 * _minimumCreditsDuration; - foreach (var episode in episodeAnalysisQueue.Where(e => !e.State.IsAnalyzed(mode))) + foreach (var episode in episodeAnalysisQueue.Where(e => !e.GetAnalyzed(mode))) { if (cancellationToken.IsCancellationRequested) { @@ -116,13 +117,13 @@ public class BlackFrameAnalyzer(ILogger logger) : IMediaFile searchStart = episode.Duration - credit.Start + (0.5 * searchDistance); creditTimes.Add(episode.EpisodeId, credit); - episode.State.SetAnalyzed(mode, true); + episode.SetAnalyzed(mode, true); } var analyzerHelper = new AnalyzerHelper(_logger); creditTimes = analyzerHelper.AdjustIntroTimes(analysisQueue, creditTimes, mode); - Plugin.Instance!.UpdateTimestamps(creditTimes, mode); + await Plugin.Instance!.UpdateTimestamps(creditTimes, mode).ConfigureAwait(false); return episodeAnalysisQueue; } diff --git a/IntroSkipper/Analyzers/ChapterAnalyzer.cs b/IntroSkipper/Analyzers/ChapterAnalyzer.cs index 733a2e6..efb272e 100644 --- a/IntroSkipper/Analyzers/ChapterAnalyzer.cs +++ b/IntroSkipper/Analyzers/ChapterAnalyzer.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Linq; using System.Text.RegularExpressions; using System.Threading; +using System.Threading.Tasks; using IntroSkipper.Configuration; using IntroSkipper.Data; using MediaBrowser.Model.Entities; @@ -26,7 +27,7 @@ public class ChapterAnalyzer(ILogger logger) : IMediaFileAnalyz private ILogger _logger = logger; /// - public IReadOnlyList AnalyzeMediaFiles( + public async Task> AnalyzeMediaFiles( IReadOnlyList analysisQueue, AnalysisMode mode, CancellationToken cancellationToken) @@ -45,7 +46,7 @@ public class ChapterAnalyzer(ILogger logger) : IMediaFileAnalyz return analysisQueue; } - foreach (var episode in episodeAnalysisQueue.Where(e => !e.State.IsAnalyzed(mode))) + foreach (var episode in episodeAnalysisQueue.Where(e => !e.GetAnalyzed(mode))) { if (cancellationToken.IsCancellationRequested) { @@ -64,10 +65,10 @@ public class ChapterAnalyzer(ILogger logger) : IMediaFileAnalyz } skippableRanges.Add(episode.EpisodeId, skipRange); - episode.State.SetAnalyzed(mode, true); + episode.SetAnalyzed(mode, true); } - Plugin.Instance.UpdateTimestamps(skippableRanges, mode); + await Plugin.Instance.UpdateTimestamps(skippableRanges, mode).ConfigureAwait(false); return episodeAnalysisQueue; } diff --git a/IntroSkipper/Analyzers/ChromaprintAnalyzer.cs b/IntroSkipper/Analyzers/ChromaprintAnalyzer.cs index 865e2b3..e6159a6 100644 --- a/IntroSkipper/Analyzers/ChromaprintAnalyzer.cs +++ b/IntroSkipper/Analyzers/ChromaprintAnalyzer.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Numerics; using System.Threading; +using System.Threading.Tasks; using IntroSkipper.Configuration; using IntroSkipper.Data; using Microsoft.Extensions.Logging; @@ -52,7 +53,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer } /// - public IReadOnlyList AnalyzeMediaFiles( + public async Task> AnalyzeMediaFiles( IReadOnlyList analysisQueue, AnalysisMode mode, CancellationToken cancellationToken) @@ -67,7 +68,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer var episodeAnalysisQueue = new List(analysisQueue); // Episodes that were analyzed and do not have an introduction. - var episodesWithoutIntros = episodeAnalysisQueue.Where(e => !e.State.IsAnalyzed(mode)).ToList(); + var episodesWithoutIntros = episodeAnalysisQueue.Where(e => !e.GetAnalyzed(mode)).ToList(); _analysisMode = mode; @@ -79,7 +80,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer var episodesWithFingerprint = new List(episodesWithoutIntros); // Load fingerprints from cache if available. - episodesWithFingerprint.AddRange(episodeAnalysisQueue.Where(e => e.State.IsAnalyzed(mode) && File.Exists(FFmpegWrapper.GetFingerprintCachePath(e, mode)))); + episodesWithFingerprint.AddRange(episodeAnalysisQueue.Where(e => e.GetAnalyzed(mode) && File.Exists(FFmpegWrapper.GetFingerprintCachePath(e, mode)))); // Ensure at least two fingerprints are present. if (episodesWithFingerprint.Count == 1) @@ -89,7 +90,9 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer .Where((episode, index) => Math.Abs(index - indexInAnalysisQueue) <= 1 && index != indexInAnalysisQueue)); } - seasonIntros = episodesWithFingerprint.Where(e => e.State.IsAnalyzed(mode)).ToDictionary(e => e.EpisodeId, e => Plugin.GetIntroByMode(e.EpisodeId, mode)); + seasonIntros = episodesWithFingerprint + .Where(e => e.GetAnalyzed(mode)) + .ToDictionary(e => e.EpisodeId, e => Plugin.Instance!.GetSegmentByMode(e.EpisodeId, mode)); // Compute fingerprints for all episodes in the season foreach (var episode in episodesWithFingerprint) @@ -193,7 +196,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer if (seasonIntros.ContainsKey(currentEpisode.EpisodeId)) { episodesWithFingerprint.Add(currentEpisode); - episodeAnalysisQueue.FirstOrDefault(x => x.EpisodeId == currentEpisode.EpisodeId)?.State.SetAnalyzed(mode, true); + episodeAnalysisQueue.FirstOrDefault(x => x.EpisodeId == currentEpisode.EpisodeId)?.SetAnalyzed(mode, true); } } @@ -207,7 +210,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer var analyzerHelper = new AnalyzerHelper(_logger); seasonIntros = analyzerHelper.AdjustIntroTimes(analysisQueue, seasonIntros, _analysisMode); - Plugin.Instance!.UpdateTimestamps(seasonIntros, _analysisMode); + await Plugin.Instance!.UpdateTimestamps(seasonIntros, _analysisMode).ConfigureAwait(false); return episodeAnalysisQueue; } diff --git a/IntroSkipper/Analyzers/IMediaFileAnalyzer.cs b/IntroSkipper/Analyzers/IMediaFileAnalyzer.cs index 32b8b5b..a57955a 100644 --- a/IntroSkipper/Analyzers/IMediaFileAnalyzer.cs +++ b/IntroSkipper/Analyzers/IMediaFileAnalyzer.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading; +using System.Threading.Tasks; using IntroSkipper.Data; namespace IntroSkipper.Analyzers; @@ -19,7 +20,7 @@ public interface IMediaFileAnalyzer /// Analysis mode. /// Cancellation token from scheduled task. /// Collection of media files that were **unsuccessfully analyzed**. - public IReadOnlyList AnalyzeMediaFiles( + Task> AnalyzeMediaFiles( IReadOnlyList analysisQueue, AnalysisMode mode, CancellationToken cancellationToken); diff --git a/IntroSkipper/Configuration/configPage.html b/IntroSkipper/Configuration/configPage.html index 271c5df..1ccf264 100644 --- a/IntroSkipper/Configuration/configPage.html +++ b/IntroSkipper/Configuration/configPage.html @@ -103,9 +103,9 @@ Modify Segment Parameters

- Changing segment parameters requires regenerating media segments before changes take effect. -
- Per the jellyfin MediaSegments API, records must be updated individually and may be slow to regenerate. + Changing segment parameters requires regenerating media segments before changes take effect. +
+ Per the jellyfin MediaSegments API, records must be updated individually and may be slow to regenerate.

@@ -242,9 +242,7 @@
-

- EDL file generation has been removed. Please use endrl's EDL plugin. -

+

EDL file generation has been removed. Please use endrl's EDL plugin.

@@ -324,9 +322,7 @@ -
- Failed to add skip button to web interface. See troubleshooting guide for the most common issues. -
+
Failed to add skip button to web interface. See troubleshooting guide for the most common issues.
User Interface Customization @@ -409,28 +405,39 @@
-