using System.Net.Http;
using Jellyfin.Plugin.Chaosflix.Api;
using Jellyfin.Plugin.Chaosflix.Channel;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using Microsoft.Extensions.DependencyInjection;
namespace Jellyfin.Plugin.Chaosflix;
///
/// Registers plugin services in the DI container.
///
public class ChaosflixServiceRegistrator : IPluginServiceRegistrator
{
///
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
// Redirect resolution needs the 302 itself, not the mirror behind it.
serviceCollection
.AddHttpClient(CccApiClient.RedirectClientName)
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
serviceCollection.AddSingleton();
// The status endpoint reports this channel's caches, so it has to reach the very
// instance Jellyfin serves from — registering the class twice would give it a
// second one with empty caches.
serviceCollection.AddSingleton();
serviceCollection.AddSingleton(sp => sp.GetRequiredService());
// Jellyfin collects the similar-items providers out of the container, the same
// way it collects channels.
serviceCollection.AddSingleton();
serviceCollection.AddHostedService();
}
}