From 58f4617ebc94a87950d2589aaa7d661d7720f758 Mon Sep 17 00:00:00 2001 From: Kilian von Pflugk Date: Sat, 20 Apr 2024 12:21:07 +0200 Subject: [PATCH] remove redundant suppression --- .../Analyzers/ChapterAnalyzer.cs | 4 ++-- .../AutoSkip.cs | 6 +++--- .../Controllers/SkipIntroController.cs | 4 ++-- .../Controllers/TroubleshootingController.cs | 8 ++++---- .../Controllers/VisualizationController.cs | 2 +- .../EdlManager.cs | 6 +++--- .../Entrypoint.cs | 18 +++++++++--------- .../Plugin.cs | 2 +- .../QueueManager.cs | 16 ++++++++-------- .../ScheduledTasks/BaseItemAnalyzerTask.cs | 12 ++++++------ 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs index d5d09bc..3e66f02 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs @@ -52,7 +52,7 @@ public class ChapterAnalyzer : IMediaFileAnalyzer var skipRange = FindMatchingChapter( episode, - new(Plugin.Instance!.GetChapters(episode.EpisodeId)), + new(Plugin.Instance.GetChapters(episode.EpisodeId)), expression, mode); @@ -64,7 +64,7 @@ public class ChapterAnalyzer : IMediaFileAnalyzer skippableRanges.Add(episode.EpisodeId, skipRange); } - Plugin.Instance!.UpdateTimestamps(skippableRanges, mode); + Plugin.Instance.UpdateTimestamps(skippableRanges, mode); return analysisQueue .Where(x => !skippableRanges.ContainsKey(x.EpisodeId)) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs index 230acec..b4685cd 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs @@ -146,7 +146,7 @@ public class AutoSkip : IHostedService, IDisposable } // Notify the user that an introduction is being skipped for them. - var notificationText = Plugin.Instance!.Configuration.AutoSkipNotificationText; + var notificationText = Plugin.Instance.Configuration.AutoSkipNotificationText; if (!string.IsNullOrWhiteSpace(notificationText)) { _sessionManager.SendMessageCommand( @@ -163,7 +163,7 @@ public class AutoSkip : IHostedService, IDisposable _logger.LogDebug("Sending seek command to {Session}", deviceId); - var introEnd = (long)intro.IntroEnd - Plugin.Instance!.Configuration.SecondsOfIntroToPlay; + var introEnd = (long)intro.IntroEnd - Plugin.Instance.Configuration.SecondsOfIntroToPlay; _sessionManager.SendPlaystateCommand( session.Id, @@ -221,7 +221,7 @@ public class AutoSkip : IHostedService, IDisposable _playbackTimer.AutoReset = true; _playbackTimer.Elapsed += PlaybackTimer_Elapsed; - AutoSkipChanged(null, Plugin.Instance!.Configuration); + AutoSkipChanged(null, Plugin.Instance.Configuration); return Task.CompletedTask; } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs index 2c261d0..2526011 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs @@ -86,7 +86,7 @@ public class SkipIntroController : ControllerBase // 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.SecondsOfIntroToPlay; if (config.PersistSkipButton) { @@ -153,7 +153,7 @@ public class SkipIntroController : ControllerBase foreach (var intro in timestamps) { // Get the details of the item from Jellyfin - var rawItem = Plugin.Instance!.GetItem(intro.Key); + var rawItem = Plugin.Instance.GetItem(intro.Key); if (rawItem is not Episode episode) { throw new InvalidCastException("Unable to cast item id " + intro.Key + " to an Episode"); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs index 0b0ab11..93be7e1 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/TroubleshootingController.cs @@ -49,11 +49,11 @@ public class TroubleshootingController : ControllerBase bundle.Append(_applicationHost.ApplicationVersionString); bundle.Append('\n'); - var version = Plugin.Instance!.Version.ToString(3); + var version = Plugin.Instance.Version.ToString(3); try { - var commit = Plugin.Instance!.GetCommit(); + var commit = Plugin.Instance.GetCommit(); if (!string.IsNullOrWhiteSpace(commit)) { version += string.Concat("+", commit.AsSpan(0, 12)); @@ -69,9 +69,9 @@ public class TroubleshootingController : ControllerBase bundle.Append('\n'); bundle.Append("* Queue contents: "); - bundle.Append(Plugin.Instance!.TotalQueued); + bundle.Append(Plugin.Instance.TotalQueued); bundle.Append(" episodes, "); - bundle.Append(Plugin.Instance!.TotalSeasons); + bundle.Append(Plugin.Instance.TotalSeasons); bundle.Append(" seasons\n"); bundle.Append("* Warnings: `"); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs index daef672..08b3a85 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/VisualizationController.cs @@ -159,7 +159,7 @@ public class VisualizationController : ControllerBase { var tr = new TimeRange(timestamps.IntroStart, timestamps.IntroEnd); Plugin.Instance!.Intros[id] = new Intro(id, tr); - Plugin.Instance!.SaveTimestamps(); + Plugin.Instance.SaveTimestamps(); return NoContent(); } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs index 0620c78..c790949 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs @@ -50,7 +50,7 @@ public static class EdlManager public static void UpdateEDLFiles(ReadOnlyCollection episodes) { var regenerate = Plugin.Instance!.Configuration.RegenerateEdlFiles; - var action = Plugin.Instance!.Configuration.EdlAction; + var action = Plugin.Instance.Configuration.EdlAction; if (action == EdlAction.None) { _logger?.LogDebug("EDL action is set to none, not updating EDL files"); @@ -63,7 +63,7 @@ public static class EdlManager { var id = episode.EpisodeId; - if (!Plugin.Instance!.Intros.TryGetValue(id, out var intro)) + if (!Plugin.Instance.Intros.TryGetValue(id, out var intro)) { _logger?.LogDebug("Episode {Id} did not have an introduction, skipping", id); continue; @@ -74,7 +74,7 @@ public static class EdlManager continue; } - var edlPath = GetEdlPath(Plugin.Instance!.GetItemPath(id)); + var edlPath = GetEdlPath(Plugin.Instance.GetItemPath(id)); _logger?.LogTrace("Episode {Id} has EDL path {Path}", id, edlPath); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs index d9c0d74..8305a4b 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs @@ -132,7 +132,7 @@ public class Entrypoint : IHostedService, IDisposable private void OnItemAdded(object? sender, ItemChangeEventArgs itemChangeEventArgs) { // Don't do anything if auto detection is disabled - if (!Plugin.Instance!.Configuration.AutoDetectIntros && !Plugin.Instance!.Configuration.AutoDetectCredits) + if (!Plugin.Instance!.Configuration.AutoDetectIntros && !Plugin.Instance.Configuration.AutoDetectCredits) { return; } @@ -148,7 +148,7 @@ public class Entrypoint : IHostedService, IDisposable return; } - Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath); + Plugin.Instance.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath); StartTimer(); } @@ -161,7 +161,7 @@ public class Entrypoint : IHostedService, IDisposable private void OnItemModified(object? sender, ItemChangeEventArgs itemChangeEventArgs) { // Don't do anything if auto detection is disabled - if (!Plugin.Instance!.Configuration.AutoDetectIntros && !Plugin.Instance!.Configuration.AutoDetectCredits) + if (!Plugin.Instance!.Configuration.AutoDetectIntros && !Plugin.Instance.Configuration.AutoDetectCredits) { return; } @@ -177,7 +177,7 @@ public class Entrypoint : IHostedService, IDisposable return; } - Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath); + Plugin.Instance.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath); StartTimer(); } @@ -190,7 +190,7 @@ public class Entrypoint : IHostedService, IDisposable private void OnLibraryRefresh(object? sender, TaskCompletionEventArgs eventArgs) { // Don't do anything if auto detection is disabled - if (!Plugin.Instance!.Configuration.AutoDetectIntros && !Plugin.Instance!.Configuration.AutoDetectCredits) + if (!Plugin.Instance!.Configuration.AutoDetectIntros && !Plugin.Instance.Configuration.AutoDetectCredits) { return; } @@ -260,7 +260,7 @@ public class Entrypoint : IHostedService, IDisposable var progress = new Progress(); var cancellationToken = _cancellationTokenSource.Token; - if (Plugin.Instance!.Configuration.AutoDetectIntros && Plugin.Instance!.Configuration.AutoDetectCredits) + if (Plugin.Instance!.Configuration.AutoDetectIntros && Plugin.Instance.Configuration.AutoDetectCredits) { // This is where we can optimize a single scan var baseIntroAnalyzer = new BaseItemAnalyzerTask( @@ -279,7 +279,7 @@ public class Entrypoint : IHostedService, IDisposable baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken); } - else if (Plugin.Instance!.Configuration.AutoDetectIntros) + else if (Plugin.Instance.Configuration.AutoDetectIntros) { var baseIntroAnalyzer = new BaseItemAnalyzerTask( AnalysisMode.Introduction, @@ -289,7 +289,7 @@ public class Entrypoint : IHostedService, IDisposable baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken); } - else if (Plugin.Instance!.Configuration.AutoDetectCredits) + else if (Plugin.Instance.Configuration.AutoDetectCredits) { var baseCreditAnalyzer = new BaseItemAnalyzerTask( AnalysisMode.Credits, @@ -301,7 +301,7 @@ public class Entrypoint : IHostedService, IDisposable } } - Plugin.Instance!.Configuration.PathRestrictions.Clear(); + Plugin.Instance.Configuration.PathRestrictions.Clear(); _autoTaskCompletEvent.Set(); _cancellationTokenSource = null; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs index cdaf54e..34f57ee 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs @@ -213,7 +213,7 @@ public class Plugin : BasePlugin, IHasWebPages // Serialize credits introList.Clear(); - foreach (var intro in Plugin.Instance!.Credits) + foreach (var intro in Plugin.Instance.Credits) { introList.Add(intro.Value); } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs index d705aa4..fe18202 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs @@ -72,11 +72,11 @@ public class QueueManager } } - Plugin.Instance!.TotalSeasons = _queuedEpisodes.Count; - Plugin.Instance!.QueuedMediaItems.Clear(); + Plugin.Instance.TotalSeasons = _queuedEpisodes.Count; + Plugin.Instance.QueuedMediaItems.Clear(); foreach (var kvp in _queuedEpisodes) { - Plugin.Instance!.QueuedMediaItems[kvp.Key] = kvp.Value; + Plugin.Instance.QueuedMediaItems[kvp.Key] = kvp.Value; } return new(_queuedEpisodes); @@ -159,7 +159,7 @@ public class QueueManager if (Plugin.Instance!.Configuration.PathRestrictions.Count > 0) { - if (!Plugin.Instance!.Configuration.PathRestrictions.Contains(item.ContainingFolderPath)) + if (!Plugin.Instance.Configuration.PathRestrictions.Contains(item.ContainingFolderPath)) { continue; } @@ -200,13 +200,13 @@ public class QueueManager fingerprintDuration = Math.Min( fingerprintDuration, - 60 * Plugin.Instance!.Configuration.AnalysisLengthLimit); + 60 * Plugin.Instance.Configuration.AnalysisLengthLimit); // Allocate a new list for each new season _queuedEpisodes.TryAdd(episode.SeasonId, new List()); // Queue the episode for analysis - var maxCreditsDuration = Plugin.Instance!.Configuration.MaximumCreditsDuration; + var maxCreditsDuration = Plugin.Instance.Configuration.MaximumCreditsDuration; _queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode() { SeriesName = episode.SeriesName, @@ -219,7 +219,7 @@ public class QueueManager CreditsFingerprintStart = Convert.ToInt32(duration - maxCreditsDuration), }); - Plugin.Instance!.TotalQueued++; + Plugin.Instance.TotalQueued++; } /// @@ -243,7 +243,7 @@ public class QueueManager { try { - var path = Plugin.Instance!.GetItemPath(candidate.EpisodeId); + var path = Plugin.Instance.GetItemPath(candidate.EpisodeId); if (File.Exists(path)) { diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs index f80f0a4..b6e4bef 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs @@ -87,7 +87,7 @@ public class BaseItemAnalyzerTask var totalProcessed = 0; var options = new ParallelOptions() { - MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism + MaxDegreeOfParallelism = Plugin.Instance.Configuration.MaxParallelism }; Parallel.ForEach(queue, options, (season) => @@ -127,7 +127,7 @@ public class BaseItemAnalyzerTask var analyzed = AnalyzeItems(episodes, cancellationToken); Interlocked.Add(ref totalProcessed, analyzed); - writeEdl = analyzed > 0 || Plugin.Instance!.Configuration.RegenerateEdlFiles; + writeEdl = analyzed > 0 || Plugin.Instance.Configuration.RegenerateEdlFiles; } catch (FingerprintException ex) { @@ -140,7 +140,7 @@ public class BaseItemAnalyzerTask if ( writeEdl && - Plugin.Instance!.Configuration.EdlAction != EdlAction.None && + Plugin.Instance.Configuration.EdlAction != EdlAction.None && _analysisMode == AnalysisMode.Introduction) { EdlManager.UpdateEDLFiles(episodes); @@ -158,11 +158,11 @@ public class BaseItemAnalyzerTask if ( _analysisMode == AnalysisMode.Introduction && - Plugin.Instance!.Configuration.RegenerateEdlFiles) + Plugin.Instance.Configuration.RegenerateEdlFiles) { _logger.LogInformation("Turning EDL file regeneration flag off"); - Plugin.Instance!.Configuration.RegenerateEdlFiles = false; - Plugin.Instance!.SaveConfiguration(); + Plugin.Instance.Configuration.RegenerateEdlFiles = false; + Plugin.Instance.SaveConfiguration(); } }