diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs index cd95c49..751540a 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs @@ -1,12 +1,13 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading; +using ConfusedPolarBear.Plugin.IntroSkipper.Configuration; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Media file analyzer used to detect end credits that consist of text overlaid on a black background. /// Bisects the end of the video file to perform an efficient search. @@ -76,7 +77,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer /// Credits timestamp. public Intro? AnalyzeMediaFile(QueuedEpisode episode, AnalysisMode mode, int minimum) { - var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration(); + var config = Plugin.Instance?.Configuration ?? new PluginConfiguration(); // Start by analyzing the last N minutes of the file. var start = TimeSpan.FromSeconds(config.MaximumCreditsDuration); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs index 3e66f02..c4216ca 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs @@ -1,5 +1,3 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -7,9 +5,12 @@ using System.Globalization; using System.Linq; using System.Text.RegularExpressions; using System.Threading; +using ConfusedPolarBear.Plugin.IntroSkipper.Configuration; using MediaBrowser.Model.Entities; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Chapter name analyzer. /// @@ -89,7 +90,7 @@ public class ChapterAnalyzer : IMediaFileAnalyzer { Intro? matchingChapter = null; - var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration(); + var config = Plugin.Instance?.Configuration ?? new PluginConfiguration(); var minDuration = config.MinimumIntroDuration; int maxDuration = mode == AnalysisMode.Introduction ? diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs index 30dd2a7..e4b9a1d 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs @@ -1,12 +1,13 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Numerics; using System.Threading; +using ConfusedPolarBear.Plugin.IntroSkipper.Configuration; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Chromaprint audio analyzer. /// @@ -38,7 +39,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer /// Logger. public ChromaprintAnalyzer(ILogger logger) { - var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration(); + var config = Plugin.Instance?.Configuration ?? new PluginConfiguration(); maximumDifferences = config.MaximumFingerprintPointDifferences; invertedIndexShift = config.InvertedIndexShift; maximumTimeSkip = config.MaximumTimeSkip; @@ -277,8 +278,8 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer if (rhsIndex.TryGetValue(modifiedPoint, out var rhsModifiedPoint)) { - var lhsFirst = (int)lhsIndex[originalPoint]; - var rhsFirst = (int)rhsModifiedPoint; + var lhsFirst = lhsIndex[originalPoint]; + var rhsFirst = rhsModifiedPoint; indexShifts.Add(rhsFirst - lhsFirst); } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/IMediaFileAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/IMediaFileAnalyzer.cs index 7721a55..047aba7 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/IMediaFileAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/IMediaFileAnalyzer.cs @@ -1,8 +1,8 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System.Collections.ObjectModel; using System.Threading; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Media file analyzer interface. /// diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs index c29ae9d..873fc7c 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/SegmentAnalyzer.cs @@ -1,9 +1,9 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System.Collections.ObjectModel; using System.Threading; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Chapter name analyzer. /// diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs index b4685cd..1904f48 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs @@ -12,6 +12,7 @@ using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Session; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Timer = System.Timers.Timer; namespace ConfusedPolarBear.Plugin.IntroSkipper; @@ -26,7 +27,7 @@ public class AutoSkip : IHostedService, IDisposable private ILogger _logger; private IUserDataManager _userDataManager; private ISessionManager _sessionManager; - private System.Timers.Timer _playbackTimer = new(1000); + private Timer _playbackTimer = new(1000); private Dictionary _sentSeekCommand; /// @@ -152,7 +153,7 @@ public class AutoSkip : IHostedService, IDisposable _sessionManager.SendMessageCommand( session.Id, session.Id, - new MessageCommand() + new MessageCommand { Header = string.Empty, // some clients require header to be a string instead of null Text = notificationText, diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/Intro.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/Intro.cs index 731778c..b1761e5 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/Intro.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/Intro.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Text.Json.Serialization; namespace ConfusedPolarBear.Plugin.IntroSkipper; @@ -102,7 +103,7 @@ public class Intro var start = Math.Round(IntroStart, 2); var end = Math.Round(IntroEnd, 2); - return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1} {2}", start, end, (int)action); + return string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", start, end, (int)action); } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs index ebced14..4103c77 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs @@ -1,7 +1,7 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Support bundle warning. /// diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs index c790949..075fa65 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs @@ -1,10 +1,10 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; using System.Collections.ObjectModel; using System.IO; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Update EDL files associated with a list of episodes. /// @@ -68,7 +68,8 @@ public static class EdlManager _logger?.LogDebug("Episode {Id} did not have an introduction, skipping", id); continue; } - else if (!intro.Valid) + + if (!intro.Valid) { _logger?.LogDebug("Episode {Id} did not have a valid introduction, skipping", id); continue; diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs index 2508c6d..db82ffa 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs @@ -206,7 +206,7 @@ public class Entrypoint : IHostedService, IDisposable } // Unless user initiated, this is likely an overlap - if (Entrypoint.AutomaticTaskState == TaskState.Running) + if (AutomaticTaskState == TaskState.Running) { return; } @@ -219,7 +219,7 @@ public class Entrypoint : IHostedService, IDisposable /// private void StartTimer() { - if (Entrypoint.AutomaticTaskState == TaskState.Running) + if (AutomaticTaskState == TaskState.Running) { _analyzeAgain = true; // Items added during a scan will be included later. } @@ -347,8 +347,6 @@ public class Entrypoint : IHostedService, IDisposable if (!dispose) { _queueTimer.Dispose(); - - return; } } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs b/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs index 81a28c9..05e048b 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs @@ -125,7 +125,7 @@ public static class FFmpegWrapper } else { - throw new ArgumentException("Unknown analysis mode " + mode.ToString()); + throw new ArgumentException("Unknown analysis mode " + mode); } return Fingerprint(episode, mode, start, end); @@ -642,14 +642,13 @@ public static class FFmpegWrapper { return basePath; } - else if (mode == AnalysisMode.Credits) + + if (mode == AnalysisMode.Credits) { return basePath + "-credits"; } - else - { - throw new ArgumentException("Unknown analysis mode " + mode.ToString()); - } + + throw new ArgumentException("Unknown analysis mode " + mode); } private static string FormatFFmpegLog(string key) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs index 29bc87a..aed7535 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs @@ -1,5 +1,3 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -9,9 +7,10 @@ using Jellyfin.Data.Enums; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Querying; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Manages enqueuing library items for analysis. /// @@ -124,7 +123,7 @@ public class QueueManager { _logger.LogDebug("Constructing anonymous internal query"); - var query = new InternalItemsQuery() + var query = new InternalItemsQuery { // Order by series name, season, and then episode number so that status updates are logged in order ParentId = id, @@ -203,7 +202,7 @@ public class QueueManager // Queue the episode for analysis var maxCreditsDuration = Plugin.Instance.Configuration.MaximumCreditsDuration; - _queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode() + _queuedEpisodes[episode.SeasonId].Add(new QueuedEpisode { SeriesName = episode.SeriesName, SeasonNumber = episode.AiredSeasonNumber ?? 0, diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs index b6e4bef..6101309 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs @@ -1,5 +1,3 @@ -namespace ConfusedPolarBear.Plugin.IntroSkipper; - using System; using System.Collections.ObjectModel; using System.Threading; @@ -7,6 +5,8 @@ using System.Threading.Tasks; using MediaBrowser.Controller.Library; using Microsoft.Extensions.Logging; +namespace ConfusedPolarBear.Plugin.IntroSkipper; + /// /// Common code shared by all media item analyzer tasks. /// @@ -85,12 +85,12 @@ public class BaseItemAnalyzerTask } var totalProcessed = 0; - var options = new ParallelOptions() + var options = new ParallelOptions { MaxDegreeOfParallelism = Plugin.Instance.Configuration.MaxParallelism }; - Parallel.ForEach(queue, options, (season) => + Parallel.ForEach(queue, options, season => { var writeEdl = false;