From d5ac3aba8c9906d0ea1c3425d92553396a3a49eb Mon Sep 17 00:00:00 2001
From: rlauu <46294892+rlauu@users.noreply.github.com>
Date: Wed, 3 Apr 2024 17:09:42 +0200
Subject: [PATCH] Auto-Detection Configuration (#106)
* Update Entrypoint.cs
* Update Entrypoint.cs
* Update Entrypoint.cs
* Update Entrypoint.cs
---
.../Entrypoint.cs | 27 ++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
index 74a81c5..07d3f94 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
@@ -62,12 +62,9 @@ public class Entrypoint : IServerEntryPoint
/// Task.
public Task RunAsync()
{
- if (Plugin.Instance!.Configuration.AutoDetectIntros || Plugin.Instance!.Configuration.AutoDetectCredits)
- {
- _libraryManager.ItemAdded += OnItemAdded;
- _libraryManager.ItemUpdated += OnItemModified;
- _taskManager.TaskCompleted += OnLibraryRefresh;
- }
+ _libraryManager.ItemAdded += OnItemAdded;
+ _libraryManager.ItemUpdated += OnItemModified;
+ _taskManager.TaskCompleted += OnLibraryRefresh;
FFmpegWrapper.Logger = _logger;
@@ -97,6 +94,12 @@ public class Entrypoint : IServerEntryPoint
/// The .
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)
+ {
+ return;
+ }
+
// Don't do anything if it's not a supported media type
if (itemChangeEventArgs.Item is not Episode)
{
@@ -118,6 +121,12 @@ public class Entrypoint : IServerEntryPoint
/// The .
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)
+ {
+ return;
+ }
+
// Don't do anything if it's not a supported media type
if (itemChangeEventArgs.Item is not Episode)
{
@@ -139,6 +148,12 @@ public class Entrypoint : IServerEntryPoint
/// The .
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)
+ {
+ return;
+ }
+
var result = eventArgs.Result;
if (result.Key != "RefreshLibrary")