feat: register services and hosted services
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Jellyfin.Plugin.Herald.Injection;
|
||||||
|
using Jellyfin.Plugin.Herald.Notices;
|
||||||
|
using Jellyfin.Plugin.Herald.Stats;
|
||||||
|
using Jellyfin.Plugin.Herald.Storage;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Plugins;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.Herald;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers the plugin's services with the server.
|
||||||
|
/// </summary>
|
||||||
|
public class PluginServiceRegistrator : IPluginServiceRegistrator
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
||||||
|
{
|
||||||
|
serviceCollection.TryAddSingleton(TimeProvider.System);
|
||||||
|
|
||||||
|
serviceCollection.AddSingleton(provider => new HeraldDatabase(
|
||||||
|
Path.Combine(provider.GetRequiredService<IApplicationPaths>().DataPath, "herald", "herald.db"),
|
||||||
|
provider.GetRequiredService<ILogger<HeraldDatabase>>()));
|
||||||
|
serviceCollection.AddSingleton<INoticeStore, SqliteNoticeStore>();
|
||||||
|
serviceCollection.AddSingleton<IWatchStatsStore, SqliteWatchStatsStore>();
|
||||||
|
|
||||||
|
serviceCollection.AddSingleton<NoticeService>();
|
||||||
|
serviceCollection.AddSingleton<StatsService>();
|
||||||
|
serviceCollection.AddSingleton(provider => new WatchTimeTracker(provider.GetRequiredService<TimeProvider>().LocalTimeZone));
|
||||||
|
|
||||||
|
serviceCollection.AddHostedService<PlaybackTrackingService>();
|
||||||
|
serviceCollection.AddHostedService<FileTransformationRegistrar>();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user