diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
index a25f555..66a4d48 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
@@ -15,7 +15,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper;
///
/// Server entrypoint.
///
-public class Entrypoint : IHostedService
+public class Entrypoint : IHostedService, IDisposable
{
private readonly IUserManager _userManager;
private readonly IUserViewManager _userViewManager;
@@ -57,6 +57,36 @@ public class Entrypoint : IHostedService
Timeout.InfiniteTimeSpan);
}
+ ///
+ public Task StartAsync(CancellationToken cancellationToken)
+ {
+ _libraryManager.ItemAdded += OnItemAdded;
+ _libraryManager.ItemUpdated += OnItemModified;
+ _taskManager.TaskCompleted += OnLibraryRefresh;
+
+ FFmpegWrapper.Logger = _logger;
+
+ try
+ {
+ // Enqueue all episodes at startup to ensure any FFmpeg errors appear as early as possible
+ _logger.LogInformation("Running startup enqueue");
+ var queueManager = new QueueManager(_loggerFactory.CreateLogger(), _libraryManager);
+ queueManager?.GetMediaItems();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError("Unable to run startup enqueue: {Exception}", ex);
+ }
+
+ return Task.CompletedTask;
+ }
+
+ ///
+ public Task StopAsync(CancellationToken cancellationToken)
+ {
+ return Task.CompletedTask;
+ }
+
// Disclose source for inspiration
// Implementation based on the principles of jellyfin-plugin-media-analyzer:
// https://github.com/endrl/jellyfin-plugin-media-analyzer
@@ -242,6 +272,7 @@ public class Entrypoint : IHostedService
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
///
@@ -261,34 +292,4 @@ public class Entrypoint : IHostedService
return;
}
}
-
- ///
- public Task StartAsync(CancellationToken cancellationToken)
- {
- _libraryManager.ItemAdded += OnItemAdded;
- _libraryManager.ItemUpdated += OnItemModified;
- _taskManager.TaskCompleted += OnLibraryRefresh;
-
- FFmpegWrapper.Logger = _logger;
-
- try
- {
- // Enqueue all episodes at startup to ensure any FFmpeg errors appear as early as possible
- _logger.LogInformation("Running startup enqueue");
- var queueManager = new QueueManager(_loggerFactory.CreateLogger(), _libraryManager);
- queueManager?.GetMediaItems();
- }
- catch (Exception ex)
- {
- _logger.LogError("Unable to run startup enqueue: {Exception}", ex);
- }
-
- return Task.CompletedTask;
- }
-
- ///
- public Task StopAsync(CancellationToken cancellationToken)
- {
- return Task.CompletedTask;
- }
}