Update Entrypoint.cs (#107)
* Update Entrypoint.cs * Update Entrypoint.cs
This commit is contained in:
parent
235e8f6494
commit
ef95f3ec25
@ -15,7 +15,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Server entrypoint.
|
/// Server entrypoint.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Entrypoint : IHostedService
|
public class Entrypoint : IHostedService, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IUserViewManager _userViewManager;
|
private readonly IUserViewManager _userViewManager;
|
||||||
@ -57,6 +57,36 @@ public class Entrypoint : IHostedService
|
|||||||
Timeout.InfiniteTimeSpan);
|
Timeout.InfiniteTimeSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
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<QueueManager>(), _libraryManager);
|
||||||
|
queueManager?.GetMediaItems();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError("Unable to run startup enqueue: {Exception}", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
// Disclose source for inspiration
|
// Disclose source for inspiration
|
||||||
// Implementation based on the principles of jellyfin-plugin-media-analyzer:
|
// Implementation based on the principles of jellyfin-plugin-media-analyzer:
|
||||||
// https://github.com/endrl/jellyfin-plugin-media-analyzer
|
// https://github.com/endrl/jellyfin-plugin-media-analyzer
|
||||||
@ -242,6 +272,7 @@ public class Entrypoint : IHostedService
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -261,34 +292,4 @@ public class Entrypoint : IHostedService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
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<QueueManager>(), _libraryManager);
|
|
||||||
queueManager?.GetMediaItems();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError("Unable to run startup enqueue: {Exception}", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user