diff options
| author | Patrick Barron <barronpm@gmail.com> | 2024-01-12 19:07:44 -0500 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2024-01-12 19:18:18 -0500 |
| commit | 449365182cb710e5d0d18b1d599a53f76b814dd8 (patch) | |
| tree | 96dffd6df945b2498b404003e81e4b726834493b | |
| parent | 063168fc1c5942e1e386eaa6f13755192a0527c4 (diff) | |
Move LiveTV service registration to extension method
| -rw-r--r-- | Jellyfin.Server/CoreAppHost.cs | 9 | ||||
| -rw-r--r-- | Jellyfin.Server/Startup.cs | 2 | ||||
| -rw-r--r-- | src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs | 25 |
3 files changed, 27 insertions, 9 deletions
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs index 5192b9e21..d5b6e93b8 100644 --- a/Jellyfin.Server/CoreAppHost.cs +++ b/Jellyfin.Server/CoreAppHost.cs @@ -7,7 +7,6 @@ using Jellyfin.Api.WebSocketListeners; using Jellyfin.Drawing; using Jellyfin.Drawing.Skia; using Jellyfin.LiveTv; -using Jellyfin.LiveTv.Channels; using Jellyfin.Server.Implementations; using Jellyfin.Server.Implementations.Activity; using Jellyfin.Server.Implementations.Devices; @@ -18,18 +17,15 @@ using Jellyfin.Server.Implementations.Users; using MediaBrowser.Controller; using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.BaseItemManager; -using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Events; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Lyrics; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Trickplay; using MediaBrowser.Model.Activity; -using MediaBrowser.Model.IO; using MediaBrowser.Providers.Lyric; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -101,11 +97,6 @@ namespace Jellyfin.Server serviceCollection.AddScoped<IAuthenticationManager, AuthenticationManager>(); - serviceCollection.AddSingleton<LiveTvDtoService>(); - serviceCollection.AddSingleton<ILiveTvManager, LiveTvManager>(); - serviceCollection.AddSingleton<IChannelManager, ChannelManager>(); - serviceCollection.AddSingleton<IStreamHelper, StreamHelper>(); - foreach (var type in GetExportTypes<ILyricProvider>()) { serviceCollection.AddSingleton(typeof(ILyricProvider), type); diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs index 1030c6f5f..7d5f22545 100644 --- a/Jellyfin.Server/Startup.cs +++ b/Jellyfin.Server/Startup.cs @@ -5,6 +5,7 @@ using System.Net.Http.Headers; using System.Net.Mime; using System.Text; using Jellyfin.Api.Middleware; +using Jellyfin.LiveTv.Extensions; using Jellyfin.MediaEncoding.Hls.Extensions; using Jellyfin.Networking; using Jellyfin.Networking.HappyEyeballs; @@ -121,6 +122,7 @@ namespace Jellyfin.Server .AddCheck<DbContextFactoryHealthCheck<JellyfinDbContext>>(nameof(JellyfinDbContext)); services.AddHlsPlaylistGenerator(); + services.AddLiveTvServices(); services.AddHostedService<AutoDiscoveryHost>(); } diff --git a/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs b/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs new file mode 100644 index 000000000..5865e88af --- /dev/null +++ b/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs @@ -0,0 +1,25 @@ +using Jellyfin.LiveTv.Channels; +using MediaBrowser.Controller.Channels; +using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.IO; +using Microsoft.Extensions.DependencyInjection; + +namespace Jellyfin.LiveTv.Extensions; + +/// <summary> +/// Live TV extensions for <see cref="IServiceCollection"/>. +/// </summary> +public static class LiveTvServiceCollectionExtensions +{ + /// <summary> + /// Adds Live TV services to the <see cref="IServiceCollection"/>. + /// </summary> + /// <param name="services">The <see cref="IServiceCollection"/> to add services to.</param> + public static void AddLiveTvServices(this IServiceCollection services) + { + services.AddSingleton<LiveTvDtoService>(); + services.AddSingleton<ILiveTvManager, LiveTvManager>(); + services.AddSingleton<IChannelManager, ChannelManager>(); + services.AddSingleton<IStreamHelper, StreamHelper>(); + } +} |
