more consolidation
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Api;
|
||||
using Jellyfin.Plugin.SRFPlay.Constants;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using MediaBrowser.Controller;
|
||||
@@ -24,11 +25,11 @@ namespace Jellyfin.Plugin.SRFPlay.Channels;
|
||||
public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
{
|
||||
private readonly ILogger<SRFPlayChannel> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly IContentRefreshService _contentRefreshService;
|
||||
private readonly IStreamUrlResolver _streamResolver;
|
||||
private readonly IMediaSourceFactory _mediaSourceFactory;
|
||||
private readonly ICategoryService? _categoryService;
|
||||
private readonly ISRFApiClientFactory _apiClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SRFPlayChannel"/> class.
|
||||
@@ -38,26 +39,28 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
/// <param name="streamResolver">The stream resolver.</param>
|
||||
/// <param name="mediaSourceFactory">The media source factory.</param>
|
||||
/// <param name="categoryService">The category service (optional).</param>
|
||||
/// <param name="apiClientFactory">The API client factory.</param>
|
||||
public SRFPlayChannel(
|
||||
ILoggerFactory loggerFactory,
|
||||
IContentRefreshService contentRefreshService,
|
||||
IStreamUrlResolver streamResolver,
|
||||
IMediaSourceFactory mediaSourceFactory,
|
||||
ICategoryService? categoryService = null)
|
||||
ICategoryService? categoryService,
|
||||
ISRFApiClientFactory apiClientFactory)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = loggerFactory.CreateLogger<SRFPlayChannel>();
|
||||
_contentRefreshService = contentRefreshService;
|
||||
_streamResolver = streamResolver;
|
||||
_mediaSourceFactory = mediaSourceFactory;
|
||||
_categoryService = categoryService;
|
||||
_apiClientFactory = apiClientFactory;
|
||||
|
||||
if (_categoryService == null)
|
||||
{
|
||||
_logger.LogWarning("CategoryService not available - category folders will be disabled");
|
||||
}
|
||||
|
||||
_logger.LogInformation("=== SRFPlayChannel constructor called! Channel is being instantiated ===");
|
||||
_logger.LogDebug("SRFPlayChannel initialized");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -236,7 +239,7 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
{
|
||||
var businessUnit = config?.BusinessUnit.ToString().ToLowerInvariant() ?? "srf";
|
||||
|
||||
using var apiClient = new Api.SRFApiClient(_loggerFactory);
|
||||
using var apiClient = _apiClientFactory.CreateClient();
|
||||
var scheduledLivestreams = await apiClient.GetScheduledLivestreamsAsync(businessUnit, "SPORT", cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (scheduledLivestreams == null)
|
||||
@@ -301,7 +304,7 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
var shows = await _categoryService.GetShowsByTopicAsync(topicId, businessUnit, 20, cancellationToken).ConfigureAwait(false);
|
||||
var urns = new List<string>();
|
||||
|
||||
using var apiClient = new Api.SRFApiClient(_loggerFactory);
|
||||
using var apiClient = _apiClientFactory.CreateClient();
|
||||
|
||||
foreach (var show in shows)
|
||||
{
|
||||
@@ -407,7 +410,7 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
||||
|
||||
_logger.LogInformation("Converting {Count} URNs to channel items", urns.Count);
|
||||
|
||||
using var apiClient = new Api.SRFApiClient(_loggerFactory);
|
||||
using var apiClient = _apiClientFactory.CreateClient();
|
||||
int successCount = 0;
|
||||
int failedCount = 0;
|
||||
int expiredCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user