remove redundant suppression

This commit is contained in:
Kilian von Pflugk 2024-04-20 12:21:07 +02:00
parent 28689a917a
commit 58f4617ebc
10 changed files with 39 additions and 39 deletions

View File

@ -52,7 +52,7 @@ public class ChapterAnalyzer : IMediaFileAnalyzer
var skipRange = FindMatchingChapter( var skipRange = FindMatchingChapter(
episode, episode,
new(Plugin.Instance!.GetChapters(episode.EpisodeId)), new(Plugin.Instance.GetChapters(episode.EpisodeId)),
expression, expression,
mode); mode);
@ -64,7 +64,7 @@ public class ChapterAnalyzer : IMediaFileAnalyzer
skippableRanges.Add(episode.EpisodeId, skipRange); skippableRanges.Add(episode.EpisodeId, skipRange);
} }
Plugin.Instance!.UpdateTimestamps(skippableRanges, mode); Plugin.Instance.UpdateTimestamps(skippableRanges, mode);
return analysisQueue return analysisQueue
.Where(x => !skippableRanges.ContainsKey(x.EpisodeId)) .Where(x => !skippableRanges.ContainsKey(x.EpisodeId))

View File

@ -146,7 +146,7 @@ public class AutoSkip : IHostedService, IDisposable
} }
// Notify the user that an introduction is being skipped for them. // 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)) if (!string.IsNullOrWhiteSpace(notificationText))
{ {
_sessionManager.SendMessageCommand( _sessionManager.SendMessageCommand(
@ -163,7 +163,7 @@ public class AutoSkip : IHostedService, IDisposable
_logger.LogDebug("Sending seek command to {Session}", deviceId); _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( _sessionManager.SendPlaystateCommand(
session.Id, session.Id,
@ -221,7 +221,7 @@ public class AutoSkip : IHostedService, IDisposable
_playbackTimer.AutoReset = true; _playbackTimer.AutoReset = true;
_playbackTimer.Elapsed += PlaybackTimer_Elapsed; _playbackTimer.Elapsed += PlaybackTimer_Elapsed;
AutoSkipChanged(null, Plugin.Instance!.Configuration); AutoSkipChanged(null, Plugin.Instance.Configuration);
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@ -86,7 +86,7 @@ public class SkipIntroController : ControllerBase
// Operate on a copy to avoid mutating the original Intro object stored in the dictionary. // Operate on a copy to avoid mutating the original Intro object stored in the dictionary.
var segment = new Intro(timestamp); var segment = new Intro(timestamp);
var config = Plugin.Instance!.Configuration; var config = Plugin.Instance.Configuration;
segment.IntroEnd -= config.SecondsOfIntroToPlay; segment.IntroEnd -= config.SecondsOfIntroToPlay;
if (config.PersistSkipButton) if (config.PersistSkipButton)
{ {
@ -153,7 +153,7 @@ public class SkipIntroController : ControllerBase
foreach (var intro in timestamps) foreach (var intro in timestamps)
{ {
// Get the details of the item from Jellyfin // 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) if (rawItem is not Episode episode)
{ {
throw new InvalidCastException("Unable to cast item id " + intro.Key + " to an Episode"); throw new InvalidCastException("Unable to cast item id " + intro.Key + " to an Episode");

View File

@ -49,11 +49,11 @@ public class TroubleshootingController : ControllerBase
bundle.Append(_applicationHost.ApplicationVersionString); bundle.Append(_applicationHost.ApplicationVersionString);
bundle.Append('\n'); bundle.Append('\n');
var version = Plugin.Instance!.Version.ToString(3); var version = Plugin.Instance.Version.ToString(3);
try try
{ {
var commit = Plugin.Instance!.GetCommit(); var commit = Plugin.Instance.GetCommit();
if (!string.IsNullOrWhiteSpace(commit)) if (!string.IsNullOrWhiteSpace(commit))
{ {
version += string.Concat("+", commit.AsSpan(0, 12)); version += string.Concat("+", commit.AsSpan(0, 12));
@ -69,9 +69,9 @@ public class TroubleshootingController : ControllerBase
bundle.Append('\n'); bundle.Append('\n');
bundle.Append("* Queue contents: "); bundle.Append("* Queue contents: ");
bundle.Append(Plugin.Instance!.TotalQueued); bundle.Append(Plugin.Instance.TotalQueued);
bundle.Append(" episodes, "); bundle.Append(" episodes, ");
bundle.Append(Plugin.Instance!.TotalSeasons); bundle.Append(Plugin.Instance.TotalSeasons);
bundle.Append(" seasons\n"); bundle.Append(" seasons\n");
bundle.Append("* Warnings: `"); bundle.Append("* Warnings: `");

View File

@ -159,7 +159,7 @@ public class VisualizationController : ControllerBase
{ {
var tr = new TimeRange(timestamps.IntroStart, timestamps.IntroEnd); var tr = new TimeRange(timestamps.IntroStart, timestamps.IntroEnd);
Plugin.Instance!.Intros[id] = new Intro(id, tr); Plugin.Instance!.Intros[id] = new Intro(id, tr);
Plugin.Instance!.SaveTimestamps(); Plugin.Instance.SaveTimestamps();
return NoContent(); return NoContent();
} }

View File

@ -50,7 +50,7 @@ public static class EdlManager
public static void UpdateEDLFiles(ReadOnlyCollection<QueuedEpisode> episodes) public static void UpdateEDLFiles(ReadOnlyCollection<QueuedEpisode> episodes)
{ {
var regenerate = Plugin.Instance!.Configuration.RegenerateEdlFiles; var regenerate = Plugin.Instance!.Configuration.RegenerateEdlFiles;
var action = Plugin.Instance!.Configuration.EdlAction; var action = Plugin.Instance.Configuration.EdlAction;
if (action == EdlAction.None) if (action == EdlAction.None)
{ {
_logger?.LogDebug("EDL action is set to none, not updating EDL files"); _logger?.LogDebug("EDL action is set to none, not updating EDL files");
@ -63,7 +63,7 @@ public static class EdlManager
{ {
var id = episode.EpisodeId; 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); _logger?.LogDebug("Episode {Id} did not have an introduction, skipping", id);
continue; continue;
@ -74,7 +74,7 @@ public static class EdlManager
continue; 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); _logger?.LogTrace("Episode {Id} has EDL path {Path}", id, edlPath);

View File

@ -132,7 +132,7 @@ public class Entrypoint : IHostedService, IDisposable
private void OnItemAdded(object? sender, ItemChangeEventArgs itemChangeEventArgs) private void OnItemAdded(object? sender, ItemChangeEventArgs itemChangeEventArgs)
{ {
// Don't do anything if auto detection is disabled // 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; return;
} }
@ -148,7 +148,7 @@ public class Entrypoint : IHostedService, IDisposable
return; return;
} }
Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath); Plugin.Instance.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath);
StartTimer(); StartTimer();
} }
@ -161,7 +161,7 @@ public class Entrypoint : IHostedService, IDisposable
private void OnItemModified(object? sender, ItemChangeEventArgs itemChangeEventArgs) private void OnItemModified(object? sender, ItemChangeEventArgs itemChangeEventArgs)
{ {
// Don't do anything if auto detection is disabled // 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; return;
} }
@ -177,7 +177,7 @@ public class Entrypoint : IHostedService, IDisposable
return; return;
} }
Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath); Plugin.Instance.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath);
StartTimer(); StartTimer();
} }
@ -190,7 +190,7 @@ public class Entrypoint : IHostedService, IDisposable
private void OnLibraryRefresh(object? sender, TaskCompletionEventArgs eventArgs) private void OnLibraryRefresh(object? sender, TaskCompletionEventArgs eventArgs)
{ {
// Don't do anything if auto detection is disabled // 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; return;
} }
@ -260,7 +260,7 @@ public class Entrypoint : IHostedService, IDisposable
var progress = new Progress<double>(); var progress = new Progress<double>();
var cancellationToken = _cancellationTokenSource.Token; 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 // This is where we can optimize a single scan
var baseIntroAnalyzer = new BaseItemAnalyzerTask( var baseIntroAnalyzer = new BaseItemAnalyzerTask(
@ -279,7 +279,7 @@ public class Entrypoint : IHostedService, IDisposable
baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken); baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken);
} }
else if (Plugin.Instance!.Configuration.AutoDetectIntros) else if (Plugin.Instance.Configuration.AutoDetectIntros)
{ {
var baseIntroAnalyzer = new BaseItemAnalyzerTask( var baseIntroAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction, AnalysisMode.Introduction,
@ -289,7 +289,7 @@ public class Entrypoint : IHostedService, IDisposable
baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken); baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);
} }
else if (Plugin.Instance!.Configuration.AutoDetectCredits) else if (Plugin.Instance.Configuration.AutoDetectCredits)
{ {
var baseCreditAnalyzer = new BaseItemAnalyzerTask( var baseCreditAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits, AnalysisMode.Credits,
@ -301,7 +301,7 @@ public class Entrypoint : IHostedService, IDisposable
} }
} }
Plugin.Instance!.Configuration.PathRestrictions.Clear(); Plugin.Instance.Configuration.PathRestrictions.Clear();
_autoTaskCompletEvent.Set(); _autoTaskCompletEvent.Set();
_cancellationTokenSource = null; _cancellationTokenSource = null;

View File

@ -213,7 +213,7 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
// Serialize credits // Serialize credits
introList.Clear(); introList.Clear();
foreach (var intro in Plugin.Instance!.Credits) foreach (var intro in Plugin.Instance.Credits)
{ {
introList.Add(intro.Value); introList.Add(intro.Value);
} }

View File

@ -72,11 +72,11 @@ public class QueueManager
} }
} }
Plugin.Instance!.TotalSeasons = _queuedEpisodes.Count; Plugin.Instance.TotalSeasons = _queuedEpisodes.Count;
Plugin.Instance!.QueuedMediaItems.Clear(); Plugin.Instance.QueuedMediaItems.Clear();
foreach (var kvp in _queuedEpisodes) foreach (var kvp in _queuedEpisodes)
{ {
Plugin.Instance!.QueuedMediaItems[kvp.Key] = kvp.Value; Plugin.Instance.QueuedMediaItems[kvp.Key] = kvp.Value;
} }
return new(_queuedEpisodes); return new(_queuedEpisodes);
@ -159,7 +159,7 @@ public class QueueManager
if (Plugin.Instance!.Configuration.PathRestrictions.Count > 0) if (Plugin.Instance!.Configuration.PathRestrictions.Count > 0)
{ {
if (!Plugin.Instance!.Configuration.PathRestrictions.Contains(item.ContainingFolderPath)) if (!Plugin.Instance.Configuration.PathRestrictions.Contains(item.ContainingFolderPath))
{ {
continue; continue;
} }
@ -200,13 +200,13 @@ public class QueueManager
fingerprintDuration = Math.Min( fingerprintDuration = Math.Min(
fingerprintDuration, fingerprintDuration,
60 * Plugin.Instance!.Configuration.AnalysisLengthLimit); 60 * Plugin.Instance.Configuration.AnalysisLengthLimit);
// Allocate a new list for each new season // Allocate a new list for each new season
_queuedEpisodes.TryAdd(episode.SeasonId, new List<QueuedEpisode>()); _queuedEpisodes.TryAdd(episode.SeasonId, new List<QueuedEpisode>());
// Queue the episode for analysis // Queue the episode for analysis
var maxCreditsDuration = Plugin.Instance!.Configuration.MaximumCreditsDuration; var maxCreditsDuration = Plugin.Instance.Configuration.MaximumCreditsDuration;
_queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode() _queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode()
{ {
SeriesName = episode.SeriesName, SeriesName = episode.SeriesName,
@ -219,7 +219,7 @@ public class QueueManager
CreditsFingerprintStart = Convert.ToInt32(duration - maxCreditsDuration), CreditsFingerprintStart = Convert.ToInt32(duration - maxCreditsDuration),
}); });
Plugin.Instance!.TotalQueued++; Plugin.Instance.TotalQueued++;
} }
/// <summary> /// <summary>
@ -243,7 +243,7 @@ public class QueueManager
{ {
try try
{ {
var path = Plugin.Instance!.GetItemPath(candidate.EpisodeId); var path = Plugin.Instance.GetItemPath(candidate.EpisodeId);
if (File.Exists(path)) if (File.Exists(path))
{ {

View File

@ -87,7 +87,7 @@ public class BaseItemAnalyzerTask
var totalProcessed = 0; var totalProcessed = 0;
var options = new ParallelOptions() var options = new ParallelOptions()
{ {
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism MaxDegreeOfParallelism = Plugin.Instance.Configuration.MaxParallelism
}; };
Parallel.ForEach(queue, options, (season) => Parallel.ForEach(queue, options, (season) =>
@ -127,7 +127,7 @@ public class BaseItemAnalyzerTask
var analyzed = AnalyzeItems(episodes, cancellationToken); var analyzed = AnalyzeItems(episodes, cancellationToken);
Interlocked.Add(ref totalProcessed, analyzed); Interlocked.Add(ref totalProcessed, analyzed);
writeEdl = analyzed > 0 || Plugin.Instance!.Configuration.RegenerateEdlFiles; writeEdl = analyzed > 0 || Plugin.Instance.Configuration.RegenerateEdlFiles;
} }
catch (FingerprintException ex) catch (FingerprintException ex)
{ {
@ -140,7 +140,7 @@ public class BaseItemAnalyzerTask
if ( if (
writeEdl && writeEdl &&
Plugin.Instance!.Configuration.EdlAction != EdlAction.None && Plugin.Instance.Configuration.EdlAction != EdlAction.None &&
_analysisMode == AnalysisMode.Introduction) _analysisMode == AnalysisMode.Introduction)
{ {
EdlManager.UpdateEDLFiles(episodes); EdlManager.UpdateEDLFiles(episodes);
@ -158,11 +158,11 @@ public class BaseItemAnalyzerTask
if ( if (
_analysisMode == AnalysisMode.Introduction && _analysisMode == AnalysisMode.Introduction &&
Plugin.Instance!.Configuration.RegenerateEdlFiles) Plugin.Instance.Configuration.RegenerateEdlFiles)
{ {
_logger.LogInformation("Turning EDL file regeneration flag off"); _logger.LogInformation("Turning EDL file regeneration flag off");
Plugin.Instance!.Configuration.RegenerateEdlFiles = false; Plugin.Instance.Configuration.RegenerateEdlFiles = false;
Plugin.Instance!.SaveConfiguration(); Plugin.Instance.SaveConfiguration();
} }
} }