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;
///
/// Registers the plugin's services with the server.
///
public class PluginServiceRegistrator : IPluginServiceRegistrator
{
///
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
serviceCollection.TryAddSingleton(TimeProvider.System);
serviceCollection.AddSingleton(provider => new HeraldDatabase(
Path.Combine(provider.GetRequiredService().DataPath, "herald", "herald.db"),
provider.GetRequiredService>()));
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
serviceCollection.AddSingleton(provider => new WatchTimeTracker(provider.GetRequiredService().LocalTimeZone));
serviceCollection.AddHostedService();
serviceCollection.AddHostedService();
}
}