diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/AnalyzerHelper.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/AnalyzerHelper.cs index ae236fb..be19a88 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/AnalyzerHelper.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/AnalyzerHelper.cs @@ -14,7 +14,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper; public class AnalyzerHelper { private readonly ILogger _logger; - private readonly double silenceDetectionMinimumDuration; + private readonly double _silenceDetectionMinimumDuration; /// /// Initializes a new instance of the class. @@ -23,7 +23,7 @@ public class AnalyzerHelper public AnalyzerHelper(ILogger logger) { var config = Plugin.Instance?.Configuration ?? new PluginConfiguration(); - silenceDetectionMinimumDuration = config.SilenceDetectionMinimumDuration; + _silenceDetectionMinimumDuration = config.SilenceDetectionMinimumDuration; _logger = logger; } @@ -126,7 +126,7 @@ public class AnalyzerHelper private bool IsValidSilenceForIntroAdjustment(TimeRange silenceRange, TimeRange originalIntroEnd, Intro adjustedIntro) { return originalIntroEnd.Intersects(silenceRange) && - silenceRange.Duration >= silenceDetectionMinimumDuration && + silenceRange.Duration >= _silenceDetectionMinimumDuration && silenceRange.Start >= adjustedIntro.IntroStart; } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs index ad79d67..172f851 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs @@ -19,11 +19,11 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer private readonly ILogger _logger; - private int minimumCreditsDuration; + private readonly int _minimumCreditsDuration; - private int maximumCreditsDuration; + private readonly int _maximumCreditsDuration; - private int blackFrameMinimumPercentage; + private readonly int _blackFrameMinimumPercentage; /// /// Initializes a new instance of the class. @@ -32,9 +32,9 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer public BlackFrameAnalyzer(ILogger logger) { var config = Plugin.Instance?.Configuration ?? new PluginConfiguration(); - minimumCreditsDuration = config.MinimumCreditsDuration; - maximumCreditsDuration = 2 * config.MaximumCreditsDuration; - blackFrameMinimumPercentage = config.BlackFrameMinimumPercentage; + _minimumCreditsDuration = config.MinimumCreditsDuration; + _maximumCreditsDuration = 2 * config.MaximumCreditsDuration; + _blackFrameMinimumPercentage = config.BlackFrameMinimumPercentage; _logger = logger; } @@ -56,9 +56,9 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer bool isFirstEpisode = true; - double searchStart = minimumCreditsDuration; + double searchStart = _minimumCreditsDuration; - var searchDistance = 2 * minimumCreditsDuration; + var searchDistance = 2 * _minimumCreditsDuration; foreach (var episode in episodeAnalysisQueue.Where(e => !e.State.IsAnalyzed(mode))) { @@ -73,7 +73,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer var scanTime = episode.Duration - searchStart; var tr = new TimeRange(scanTime - 0.5, scanTime); // Short search range since accuracy isn't important here. - var frames = FFmpegWrapper.DetectBlackFrames(episode, tr, blackFrameMinimumPercentage); + var frames = FFmpegWrapper.DetectBlackFrames(episode, tr, _blackFrameMinimumPercentage); while (frames.Length > 0) // While black frames are found increase searchStart { @@ -82,16 +82,16 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer scanTime = episode.Duration - searchStart; tr = new TimeRange(scanTime - 0.5, scanTime); - frames = FFmpegWrapper.DetectBlackFrames(episode, tr, blackFrameMinimumPercentage); + frames = FFmpegWrapper.DetectBlackFrames(episode, tr, _blackFrameMinimumPercentage); - if (searchStart > maximumCreditsDuration) + if (searchStart > _maximumCreditsDuration) { - searchStart = maximumCreditsDuration; + searchStart = _maximumCreditsDuration; break; } } - if (searchStart == minimumCreditsDuration) // Skip if no black frames were found + if (searchStart == _minimumCreditsDuration) // Skip if no black frames were found { continue; } @@ -103,12 +103,12 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer episode, searchStart, searchDistance, - blackFrameMinimumPercentage); + _blackFrameMinimumPercentage); if (credit is null) { // If no credits were found, reset the first-episode search logic for the next episode in the sequence. - searchStart = minimumCreditsDuration; + searchStart = _minimumCreditsDuration; isFirstEpisode = true; continue; } @@ -139,7 +139,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer { // Start by analyzing the last N minutes of the file. var upperLimit = searchStart; - var lowerLimit = Math.Max(searchStart - searchDistance, minimumCreditsDuration); + var lowerLimit = Math.Max(searchStart - searchDistance, _minimumCreditsDuration); var start = TimeSpan.FromSeconds(upperLimit); var end = TimeSpan.FromSeconds(lowerLimit); var firstFrameTime = 0.0; @@ -176,7 +176,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer if (midpoint - TimeSpan.FromSeconds(lowerLimit) < _maximumError) { - lowerLimit = Math.Max(lowerLimit - (0.5 * searchDistance), minimumCreditsDuration); + lowerLimit = Math.Max(lowerLimit - (0.5 * searchDistance), _minimumCreditsDuration); // Reset end for a new search with the increased duration end = TimeSpan.FromSeconds(lowerLimit); @@ -190,7 +190,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer if (TimeSpan.FromSeconds(upperLimit) - midpoint < _maximumError) { - upperLimit = Math.Min(upperLimit + (0.5 * searchDistance), maximumCreditsDuration); + upperLimit = Math.Min(upperLimit + (0.5 * searchDistance), _maximumCreditsDuration); // Reset start for a new search with the increased duration start = TimeSpan.FromSeconds(upperLimit); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs index 7b5144c..ba82762 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs @@ -22,15 +22,15 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer /// private const double SamplesToSeconds = 0.1238; - private int minimumIntroDuration; + private readonly int _minimumIntroDuration; - private int maximumDifferences; + private readonly int _maximumDifferences; - private int invertedIndexShift; + private readonly int _invertedIndexShift; - private double maximumTimeSkip; + private readonly double _maximumTimeSkip; - private ILogger _logger; + private readonly ILogger _logger; private AnalysisMode _analysisMode; @@ -41,10 +41,10 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer public ChromaprintAnalyzer(ILogger logger) { var config = Plugin.Instance?.Configuration ?? new PluginConfiguration(); - maximumDifferences = config.MaximumFingerprintPointDifferences; - invertedIndexShift = config.InvertedIndexShift; - maximumTimeSkip = config.MaximumTimeSkip; - minimumIntroDuration = config.MinimumIntroDuration; + _maximumDifferences = config.MaximumFingerprintPointDifferences; + _invertedIndexShift = config.InvertedIndexShift; + _maximumTimeSkip = config.MaximumTimeSkip; + _minimumIntroDuration = config.MinimumIntroDuration; _logger = logger; } @@ -87,7 +87,7 @@ 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.Instance!.GetIntroByMode(e.EpisodeId, mode)); + seasonIntros = episodesWithFingerprint.Where(e => e.State.IsAnalyzed(mode)).ToDictionary(e => e.EpisodeId, e => Plugin.GetIntroByMode(e.EpisodeId, mode)); // Compute fingerprints for all episodes in the season foreach (var episode in episodesWithFingerprint) @@ -113,7 +113,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer WarningManager.SetFlag(PluginWarning.InvalidChromaprintFingerprint); // Fallback to an empty fingerprint on any error - fingerprintCache[episode.EpisodeId] = Array.Empty(); + fingerprintCache[episode.EpisodeId] = []; } } @@ -203,7 +203,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer // Adjust all introduction times. var analyzerHelper = new AnalyzerHelper(_logger); - seasonIntros = analyzerHelper.AdjustIntroTimes(analysisQueue, seasonIntros, this._analysisMode); + seasonIntros = analyzerHelper.AdjustIntroTimes(analysisQueue, seasonIntros, _analysisMode); Plugin.Instance!.UpdateTimestamps(seasonIntros, _analysisMode); @@ -307,7 +307,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer { var originalPoint = kvp.Key; - for (var i = -1 * invertedIndexShift; i <= invertedIndexShift; i++) + for (var i = -1 * _invertedIndexShift; i <= _invertedIndexShift; i++) { var modifiedPoint = (uint)(originalPoint + i); @@ -372,7 +372,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer var diff = lhs[lhsPosition] ^ rhs[rhsPosition]; // If the difference between the samples is small, flag both times as similar. - if (CountBits(diff) > maximumDifferences) + if (CountBits(diff) > _maximumDifferences) { continue; } @@ -389,14 +389,14 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer rhsTimes.Add(double.MaxValue); // Now that both fingerprints have been compared at this shift, see if there's a contiguous time range. - var lContiguous = TimeRangeHelpers.FindContiguous(lhsTimes.ToArray(), maximumTimeSkip); - if (lContiguous is null || lContiguous.Duration < minimumIntroDuration) + var lContiguous = TimeRangeHelpers.FindContiguous(lhsTimes.ToArray(), _maximumTimeSkip); + if (lContiguous is null || lContiguous.Duration < _minimumIntroDuration) { return (new TimeRange(), new TimeRange()); } // Since LHS had a contiguous time range, RHS must have one also. - var rContiguous = TimeRangeHelpers.FindContiguous(rhsTimes.ToArray(), maximumTimeSkip)!; + var rContiguous = TimeRangeHelpers.FindContiguous(rhsTimes.ToArray(), _maximumTimeSkip)!; return (lContiguous, rContiguous); } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs index 6fa0db8..9cb15b8 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs @@ -10,7 +10,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Analyzers; /// public class SegmentAnalyzer : IMediaFileAnalyzer { - private ILogger _logger; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs index f6face2..33b5770 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs @@ -71,7 +71,7 @@ public class PluginConfiguration : BasePluginConfiguration /// By default, EDL files are only written for a season if the season had at least one newly analyzed episode. /// If this is set, all EDL files will be regenerated and overwrite any existing EDL file. /// - public bool RegenerateEdlFiles { get; set; } = false; + public bool RegenerateEdlFiles { get; set; } // ===== Custom analysis settings ===== @@ -172,7 +172,7 @@ public class PluginConfiguration : BasePluginConfiguration /// /// Gets or sets the amount of credit at start to play (in seconds). /// - public int SecondsOfCreditsStartToPlay { get; set; } = 0; + public int SecondsOfCreditsStartToPlay { get; set; } // ===== Internal algorithm settings ===== @@ -228,7 +228,7 @@ public class PluginConfiguration : BasePluginConfiguration /// /// Gets or sets the number of threads for an ffmpeg process. /// - public int ProcessThreads { get; set; } = 0; + public int ProcessThreads { get; set; } /// /// Gets or sets the relative priority for an ffmpeg process. diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/UserInterfaceConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/UserInterfaceConfiguration.cs index 05ee453..1680705 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/UserInterfaceConfiguration.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/UserInterfaceConfiguration.cs @@ -3,33 +3,26 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Configuration; /// /// User interface configuration. /// -public class UserInterfaceConfiguration +/// +/// Initializes a new instance of the class. +/// +/// Skip button visibility. +/// Skip button intro text. +/// Skip button end credits text. +public class UserInterfaceConfiguration(bool visible, string introText, string creditsText) { - /// - /// Initializes a new instance of the class. - /// - /// Skip button visibility. - /// Skip button intro text. - /// Skip button end credits text. - public UserInterfaceConfiguration(bool visible, string introText, string creditsText) - { - SkipButtonVisible = visible; - SkipButtonIntroText = introText; - SkipButtonEndCreditsText = creditsText; - } - /// /// Gets or sets a value indicating whether to show the skip intro button. /// - public bool SkipButtonVisible { get; set; } + public bool SkipButtonVisible { get; set; } = visible; /// /// Gets or sets the text to display in the skip intro button in introduction mode. /// - public string SkipButtonIntroText { get; set; } + public string SkipButtonIntroText { get; set; } = introText; /// /// Gets or sets the text to display in the skip intro button in end credits mode. /// - public string SkipButtonEndCreditsText { get; set; } + public string SkipButtonEndCreditsText { get; set; } = creditsText; } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs index cf0203b..6944988 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs @@ -146,16 +146,16 @@ public class SkipIntroController : ControllerBase /// Unique identifier of this episode. /// Mode. /// Intro object if the provided item has an intro, null otherwise. - private Intro? GetIntro(Guid id, AnalysisMode mode) + private static Intro? GetIntro(Guid id, AnalysisMode mode) { try { - var timestamp = Plugin.Instance!.GetIntroByMode(id, mode); + var timestamp = Plugin.GetIntroByMode(id, mode); // Operate on a copy to avoid mutating the original Intro object stored in the dictionary. var segment = new Intro(timestamp); - var config = Plugin.Instance.Configuration; + var config = Plugin.Instance!.Configuration; segment.IntroEnd -= config.RemainingSecondsOfIntro; if (config.PersistSkipButton) { @@ -219,7 +219,7 @@ public class SkipIntroController : ControllerBase public ActionResult> GetAllTimestamps( [FromQuery] AnalysisMode mode = AnalysisMode.Introduction) { - List intros = new(); + List intros = []; var timestamps = mode == AnalysisMode.Introduction ? Plugin.Instance!.Intros : diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs index ef96236..f042c78 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs @@ -135,7 +135,7 @@ public class TroubleshootingController : ControllerBase return bundle.ToString().TrimEnd('\n'); } - private string GetHumanReadableSize(long bytes) + private static string GetHumanReadableSize(long bytes) { string[] sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; double len = bytes; @@ -144,7 +144,7 @@ public class TroubleshootingController : ControllerBase while (len >= 1024 && order < sizes.Length - 1) { order++; - len = len / 1024; + len /= 1024; } return $"{len:0.##} {sizes[order]}"; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs index cd2d1ec..daf2407 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs @@ -178,7 +178,7 @@ public class VisualizationController : ControllerBase return NoContent(); } - private string GetSeasonName(QueuedEpisode episode) + private static string GetSeasonName(QueuedEpisode episode) { return "Season " + episode.SeasonNumber.ToString(CultureInfo.InvariantCulture); } @@ -190,7 +190,7 @@ public class VisualizationController : ControllerBase /// Season name. /// Episodes. /// Boolean indicating if the requested season was found. - private bool LookupSeasonByName(string series, string season, out List episodes) + private static bool LookupSeasonByName(string series, string season, out List episodes) { foreach (var queuedEpisodes in Plugin.Instance!.QueuedMediaItems) { @@ -209,7 +209,7 @@ public class VisualizationController : ControllerBase return true; } - episodes = new List(); + episodes = []; return false; } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/BlackFrame.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/BlackFrame.cs index 4f71be1..5eefe24 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/BlackFrame.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/BlackFrame.cs @@ -3,26 +3,20 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Data; /// /// A frame of video that partially (or entirely) consists of black pixels. /// -public class BlackFrame +/// +/// Initializes a new instance of the class. +/// +/// Percentage of the frame that is black. +/// Time this frame appears at. +public class BlackFrame(int percent, double time) { - /// - /// Initializes a new instance of the class. - /// - /// Percentage of the frame that is black. - /// Time this frame appears at. - public BlackFrame(int percent, double time) - { - Percentage = percent; - Time = time; - } - /// /// Gets or sets the percentage of the frame that is black. /// - public int Percentage { get; set; } + public int Percentage { get; set; } = percent; /// /// Gets or sets the time (in seconds) this frame appeared at. /// - public double Time { get; set; } + public double Time { get; set; } = time; } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/EpisodeVisualization.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/EpisodeVisualization.cs index 2c8a206..0e67101 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/EpisodeVisualization.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/EpisodeVisualization.cs @@ -5,26 +5,20 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Data; /// /// Episode name and internal ID as returned by the visualization controller. /// -public class EpisodeVisualization +/// +/// Initializes a new instance of the class. +/// +/// Episode id. +/// Episode name. +public class EpisodeVisualization(Guid id, string name) { - /// - /// Initializes a new instance of the class. - /// - /// Episode id. - /// Episode name. - public EpisodeVisualization(Guid id, string name) - { - Id = id; - Name = name; - } - /// /// Gets the id. /// - public Guid Id { get; private set; } + public Guid Id { get; private set; } = id; /// /// Gets the name. /// - public string Name { get; private set; } = string.Empty; + public string Name { get; private set; } = name; } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs index c58c28e..572b87a 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/QueuedEpisode.cs @@ -40,7 +40,7 @@ public class QueuedEpisode /// /// Gets or sets a value indicating whether an episode is Anime. /// - public bool IsAnime { get; set; } = false; + public bool IsAnime { get; set; } /// /// Gets or sets the timestamp (in seconds) to stop searching for an introduction at. diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRange.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRange.cs index af1368a..2daae19 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRange.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRange.cs @@ -61,7 +61,7 @@ public class TimeRange : IComparable /// int. public int CompareTo(object? obj) { - if (!(obj is TimeRange tr)) + if (obj is not TimeRange tr) { throw new ArgumentException("obj must be a TimeRange"); } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRangeHelpers.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRangeHelpers.cs index 96fe7d7..57c936b 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRangeHelpers.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/TimeRangeHelpers.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; namespace ConfusedPolarBear.Plugin.IntroSkipper.Data; -#pragma warning restore CA1036 /// /// Time range helpers. diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/WarningManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/WarningManager.cs index 83d240f..34afbeb 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/WarningManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/WarningManager.cs @@ -5,7 +5,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Data; /// public static class WarningManager { - private static PluginWarning warnings; + private static PluginWarning _warnings; /// /// Set warning. @@ -13,7 +13,7 @@ public static class WarningManager /// Warning. public static void SetFlag(PluginWarning warning) { - warnings |= warning; + _warnings |= warning; } /// @@ -21,7 +21,7 @@ public static class WarningManager /// public static void Clear() { - warnings = PluginWarning.None; + _warnings = PluginWarning.None; } /// @@ -30,7 +30,7 @@ public static class WarningManager /// Warnings. public static string GetWarnings() { - return warnings.ToString(); + return _warnings.ToString(); } /// @@ -40,6 +40,6 @@ public static class WarningManager /// True if the flag is set, otherwise false. public static bool HasFlag(PluginWarning warning) { - return (warnings & warning) == warning; + return (_warnings & warning) == warning; } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs index 3d2457b..9353ba5 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Threading; using System.Threading.Tasks; using ConfusedPolarBear.Plugin.IntroSkipper.Data; @@ -19,38 +18,30 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper; /// public class Entrypoint : IHostedService, IDisposable { - private readonly IUserManager _userManager; - private readonly IUserViewManager _userViewManager; private readonly ITaskManager _taskManager; private readonly ILibraryManager _libraryManager; private readonly ILogger _logger; private readonly ILoggerFactory _loggerFactory; - private Timer _queueTimer; + private readonly HashSet _seasonsToAnalyze = []; + private readonly Timer _queueTimer; + private static readonly ManualResetEventSlim _autoTaskCompletEvent = new(false); private bool _disposed; private bool _analyzeAgain; - private HashSet _seasonsToAnalyze = new HashSet(); private static CancellationTokenSource? _cancellationTokenSource; - private static ManualResetEventSlim _autoTaskCompletEvent = new ManualResetEventSlim(false); /// /// Initializes a new instance of the class. /// - /// User manager. - /// User view manager. /// Library manager. /// Task manager. /// Logger. /// Logger factory. public Entrypoint( - IUserManager userManager, - IUserViewManager userViewManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ILoggerFactory loggerFactory) { - _userManager = userManager; - _userViewManager = userViewManager; _libraryManager = libraryManager; _taskManager = taskManager; _logger = logger; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs b/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs index ca7f3b6..eb0276a 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs @@ -14,25 +14,24 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper; /// /// Wrapper for libchromaprint and the silencedetect filter. /// -public static class FFmpegWrapper +public static partial class FFmpegWrapper { /// /// Used with FFmpeg's silencedetect filter to extract the start and end times of silence. /// - private static readonly Regex SilenceDetectionExpression = new( - "silence_(?start|end): (?