Files
jellyfin-herald/Jellyfin.Plugin.Herald/PluginServiceRegistrator.cs
T

40 lines
1.6 KiB
C#

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>();
}
}