Use depencency injection for ISubtitleProvider

This commit is contained in:
Patrick Barron 2023-01-27 18:41:10 -05:00
parent 8898012121
commit 4f81f4daaa
3 changed files with 6 additions and 18 deletions

View File

@ -728,8 +728,6 @@ namespace Emby.Server.Implementations
Resolve<ILiveTvManager>().AddParts(GetExports<ILiveTvService>(), GetExports<ITunerHost>(), GetExports<IListingsProvider>());
Resolve<ISubtitleManager>().AddParts(GetExports<ISubtitleProvider>());
Resolve<IChannelManager>().AddParts(GetExports<IChannel>());
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());

View File

@ -19,12 +19,6 @@ namespace MediaBrowser.Controller.Subtitles
/// </summary>
event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
/// <summary>
/// Adds the parts.
/// </summary>
/// <param name="subtitleProviders">The subtitle providers.</param>
void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders);
/// <summary>
/// Searches the subtitles.
/// </summary>

View File

@ -35,33 +35,29 @@ namespace MediaBrowser.Providers.Subtitles
private readonly IMediaSourceManager _mediaSourceManager;
private readonly ILocalizationManager _localization;
private ISubtitleProvider[] _subtitleProviders;
private readonly ISubtitleProvider[] _subtitleProviders;
public SubtitleManager(
ILogger<SubtitleManager> logger,
IFileSystem fileSystem,
ILibraryMonitor monitor,
IMediaSourceManager mediaSourceManager,
ILocalizationManager localizationManager)
ILocalizationManager localizationManager,
IEnumerable<ISubtitleProvider> subtitleProviders)
{
_logger = logger;
_fileSystem = fileSystem;
_monitor = monitor;
_mediaSourceManager = mediaSourceManager;
_localization = localizationManager;
}
/// <inheritdoc />
public event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
/// <inheritdoc />
public void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders)
{
_subtitleProviders = subtitleProviders
.OrderBy(i => i is IHasOrder hasOrder ? hasOrder.Order : 0)
.ToArray();
}
/// <inheritdoc />
public event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
/// <inheritdoc />
public async Task<RemoteSubtitleInfo[]> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
{