refactor to unify data fetching and define abstract API for re-use
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Api;
|
||||
using Jellyfin.Plugin.SRFPlay.Api.Models;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.SRFPlay.Services;
|
||||
@@ -12,24 +12,22 @@ namespace Jellyfin.Plugin.SRFPlay.Services;
|
||||
/// <summary>
|
||||
/// Service for refreshing content from SRF API.
|
||||
/// </summary>
|
||||
public class ContentRefreshService
|
||||
public class ContentRefreshService : IContentRefreshService
|
||||
{
|
||||
private readonly ILogger<ContentRefreshService> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly MetadataCache _metadataCache;
|
||||
private readonly ISRFApiClientFactory _apiClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentRefreshService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="metadataCache">The metadata cache.</param>
|
||||
/// <param name="apiClientFactory">The API client factory.</param>
|
||||
public ContentRefreshService(
|
||||
ILoggerFactory loggerFactory,
|
||||
MetadataCache metadataCache)
|
||||
ISRFApiClientFactory apiClientFactory)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = loggerFactory.CreateLogger<ContentRefreshService>();
|
||||
_metadataCache = metadataCache;
|
||||
_apiClientFactory = apiClientFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,7 +50,7 @@ public class ContentRefreshService
|
||||
|
||||
_logger.LogInformation("Refreshing latest content for business unit: {BusinessUnit}", config.BusinessUnit);
|
||||
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
using var apiClient = _apiClientFactory.CreateClient();
|
||||
var businessUnit = config.BusinessUnit.ToString().ToLowerInvariant();
|
||||
|
||||
// Get all shows from Play v3 API
|
||||
@@ -167,7 +165,7 @@ public class ContentRefreshService
|
||||
|
||||
_logger.LogInformation("Refreshing trending content for business unit: {BusinessUnit}", config.BusinessUnit);
|
||||
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
using var apiClient = _apiClientFactory.CreateClient();
|
||||
var businessUnit = config.BusinessUnit.ToString().ToLowerInvariant();
|
||||
|
||||
// Get all shows from Play v3 API
|
||||
|
||||
Reference in New Issue
Block a user