refactor to unify data fetching and define abstract API for re-use
This commit is contained in:
@@ -4,8 +4,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Api;
|
||||
using Jellyfin.Plugin.SRFPlay.Services;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -20,25 +19,23 @@ namespace Jellyfin.Plugin.SRFPlay.Providers;
|
||||
public class SRFEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>
|
||||
{
|
||||
private readonly ILogger<SRFEpisodeProvider> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly MetadataCache _metadataCache;
|
||||
private readonly IMediaCompositionFetcher _compositionFetcher;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SRFEpisodeProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="httpClientFactory">The HTTP client factory.</param>
|
||||
/// <param name="metadataCache">The metadata cache.</param>
|
||||
/// <param name="compositionFetcher">The media composition fetcher.</param>
|
||||
public SRFEpisodeProvider(
|
||||
ILoggerFactory loggerFactory,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
MetadataCache metadataCache)
|
||||
IMediaCompositionFetcher compositionFetcher)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = loggerFactory.CreateLogger<SRFEpisodeProvider>();
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_metadataCache = metadataCache;
|
||||
_compositionFetcher = compositionFetcher;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -56,26 +53,7 @@ public class SRFEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>
|
||||
{
|
||||
_logger.LogDebug("Searching for episode with URN: {Urn}", urn);
|
||||
|
||||
var config = Plugin.Instance?.Configuration;
|
||||
if (config == null)
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
// Try cache first
|
||||
var mediaComposition = _metadataCache.GetMediaComposition(urn, config.CacheDurationMinutes);
|
||||
|
||||
// If not in cache, fetch from API
|
||||
if (mediaComposition == null)
|
||||
{
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
mediaComposition = await apiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition != null)
|
||||
{
|
||||
_metadataCache.SetMediaComposition(urn, mediaComposition);
|
||||
}
|
||||
}
|
||||
var mediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition?.ChapterList != null && mediaComposition.ChapterList.Count > 0)
|
||||
{
|
||||
@@ -118,26 +96,7 @@ public class SRFEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>
|
||||
|
||||
_logger.LogDebug("Fetching metadata for episode URN: {Urn}", urn);
|
||||
|
||||
var config = Plugin.Instance?.Configuration;
|
||||
if (config == null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Try cache first
|
||||
var mediaComposition = _metadataCache.GetMediaComposition(urn, config.CacheDurationMinutes);
|
||||
|
||||
// If not in cache, fetch from API
|
||||
if (mediaComposition == null)
|
||||
{
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
mediaComposition = await apiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition != null)
|
||||
{
|
||||
_metadataCache.SetMediaComposition(urn, mediaComposition);
|
||||
}
|
||||
}
|
||||
var mediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition?.ChapterList == null || mediaComposition.ChapterList.Count == 0)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Api;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -21,18 +21,22 @@ public class SRFImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILogger<SRFImageProvider> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly IMediaCompositionFetcher _compositionFetcher;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SRFImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The HTTP client factory.</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
public SRFImageProvider(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory)
|
||||
/// <param name="compositionFetcher">The media composition fetcher.</param>
|
||||
public SRFImageProvider(
|
||||
IHttpClientFactory httpClientFactory,
|
||||
ILoggerFactory loggerFactory,
|
||||
IMediaCompositionFetcher compositionFetcher)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = loggerFactory.CreateLogger<SRFImageProvider>();
|
||||
_compositionFetcher = compositionFetcher;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -78,8 +82,7 @@ public class SRFImageProvider : IRemoteImageProvider, IHasOrder
|
||||
_logger.LogDebug("Fetching images for SRF URN: {Urn}", urn);
|
||||
|
||||
// Fetch media composition to get image URLs
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
var mediaComposition = await apiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
var mediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition == null)
|
||||
{
|
||||
@@ -151,9 +154,69 @@ public class SRFImageProvider : IRemoteImageProvider, IHasOrder
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
public async Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
|
||||
return httpClient.GetAsync(new Uri(url), cancellationToken);
|
||||
|
||||
// Create request with proper headers - SRF CDN requires User-Agent
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
|
||||
request.Headers.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||
request.Headers.Accept.ParseAdd("image/*");
|
||||
|
||||
var response = await httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Fix Content-Type if it's binary/octet-stream - SRF CDN returns wrong content type
|
||||
// Jellyfin needs correct Content-Type to process images
|
||||
if (response.IsSuccessStatusCode &&
|
||||
response.Content.Headers.ContentType?.MediaType == "binary/octet-stream")
|
||||
{
|
||||
// Determine correct content type from URL extension
|
||||
var contentType = GetContentTypeFromUrl(url);
|
||||
if (!string.IsNullOrEmpty(contentType))
|
||||
{
|
||||
_logger.LogDebug("Fixing Content-Type from binary/octet-stream to {ContentType} for {Url}", contentType, url);
|
||||
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the correct content type based on URL file extension.
|
||||
/// </summary>
|
||||
private static string? GetContentTypeFromUrl(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the file extension from the URL (ignore query string)
|
||||
var uri = new Uri(url);
|
||||
var path = uri.AbsolutePath.ToLowerInvariant();
|
||||
|
||||
if (path.EndsWith(".jpg", StringComparison.Ordinal) || path.EndsWith(".jpeg", StringComparison.Ordinal))
|
||||
{
|
||||
return "image/jpeg";
|
||||
}
|
||||
|
||||
if (path.EndsWith(".png", StringComparison.Ordinal))
|
||||
{
|
||||
return "image/png";
|
||||
}
|
||||
|
||||
if (path.EndsWith(".gif", StringComparison.Ordinal))
|
||||
{
|
||||
return "image/gif";
|
||||
}
|
||||
|
||||
if (path.EndsWith(".webp", StringComparison.Ordinal))
|
||||
{
|
||||
return "image/webp";
|
||||
}
|
||||
|
||||
// Default to JPEG for SRF images (most common)
|
||||
return "image/jpeg";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Services;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -15,7 +15,7 @@ namespace Jellyfin.Plugin.SRFPlay.Providers;
|
||||
internal sealed class SRFLiveStream : ILiveStream
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly StreamProxyService _proxyService;
|
||||
private readonly IStreamProxyService _proxyService;
|
||||
private readonly string _originalItemId;
|
||||
private MediaSourceInfo? _mediaSource;
|
||||
|
||||
@@ -26,13 +26,11 @@ internal sealed class SRFLiveStream : ILiveStream
|
||||
/// <param name="proxyService">The stream proxy service.</param>
|
||||
/// <param name="originalItemId">The original item ID.</param>
|
||||
/// <param name="openToken">The open token.</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
public SRFLiveStream(
|
||||
ILogger logger,
|
||||
StreamProxyService proxyService,
|
||||
IStreamProxyService proxyService,
|
||||
string originalItemId,
|
||||
string openToken,
|
||||
ILoggerFactory loggerFactory)
|
||||
string openToken)
|
||||
{
|
||||
_logger = logger;
|
||||
_proxyService = proxyService;
|
||||
|
||||
@@ -4,8 +4,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Api;
|
||||
using Jellyfin.Plugin.SRFPlay.Services;
|
||||
using Jellyfin.Plugin.SRFPlay.Configuration;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -23,9 +23,9 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
{
|
||||
private readonly ILogger<SRFMediaProvider> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly MetadataCache _metadataCache;
|
||||
private readonly StreamUrlResolver _streamResolver;
|
||||
private readonly StreamProxyService _proxyService;
|
||||
private readonly IMediaCompositionFetcher _compositionFetcher;
|
||||
private readonly IStreamUrlResolver _streamResolver;
|
||||
private readonly IStreamProxyService _proxyService;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly Dictionary<string, string> _openTokenToItemId = new();
|
||||
|
||||
@@ -33,20 +33,20 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
/// Initializes a new instance of the <see cref="SRFMediaProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="metadataCache">The metadata cache.</param>
|
||||
/// <param name="compositionFetcher">The media composition fetcher.</param>
|
||||
/// <param name="streamResolver">The stream URL resolver.</param>
|
||||
/// <param name="proxyService">The stream proxy service.</param>
|
||||
/// <param name="appHost">The server application host.</param>
|
||||
public SRFMediaProvider(
|
||||
ILoggerFactory loggerFactory,
|
||||
MetadataCache metadataCache,
|
||||
StreamUrlResolver streamResolver,
|
||||
StreamProxyService proxyService,
|
||||
IMediaCompositionFetcher compositionFetcher,
|
||||
IStreamUrlResolver streamResolver,
|
||||
IStreamProxyService proxyService,
|
||||
IServerApplicationHost appHost)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = loggerFactory.CreateLogger<SRFMediaProvider>();
|
||||
_metadataCache = metadataCache;
|
||||
_compositionFetcher = compositionFetcher;
|
||||
_streamResolver = streamResolver;
|
||||
_proxyService = proxyService;
|
||||
_appHost = appHost;
|
||||
@@ -88,32 +88,10 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
|
||||
_logger.LogInformation("Getting media sources for URN: {Urn}, Item: {ItemName}", urn, item.Name);
|
||||
|
||||
var config = Plugin.Instance?.Configuration;
|
||||
if (config == null)
|
||||
{
|
||||
return sources;
|
||||
}
|
||||
|
||||
// For scheduled livestreams, use shorter cache TTL (5 minutes) so they refresh when they go live
|
||||
// For regular content, use configured cache duration
|
||||
var cacheDuration = urn.Contains("scheduled_livestream", StringComparison.OrdinalIgnoreCase)
|
||||
? 5
|
||||
: config.CacheDurationMinutes;
|
||||
var cacheDuration = urn.Contains("scheduled_livestream", StringComparison.OrdinalIgnoreCase) ? 5 : (int?)null;
|
||||
|
||||
// Try cache first
|
||||
var mediaComposition = _metadataCache.GetMediaComposition(urn, cacheDuration);
|
||||
|
||||
// If not in cache, fetch from API
|
||||
if (mediaComposition == null)
|
||||
{
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
mediaComposition = await apiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition != null)
|
||||
{
|
||||
_metadataCache.SetMediaComposition(urn, mediaComposition);
|
||||
}
|
||||
}
|
||||
var mediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken, cacheDuration).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition?.ChapterList == null || mediaComposition.ChapterList.Count == 0)
|
||||
{
|
||||
@@ -139,25 +117,25 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
}
|
||||
|
||||
// Get stream URL based on quality preference
|
||||
var streamUrl = _streamResolver.GetStreamUrl(chapter, config.QualityPreference);
|
||||
var config = Plugin.Instance?.Configuration;
|
||||
var qualityPref = config?.QualityPreference ?? QualityPreference.HD;
|
||||
var streamUrl = _streamResolver.GetStreamUrl(chapter, qualityPref);
|
||||
|
||||
// For scheduled livestreams, always fetch fresh data to ensure stream URL is current
|
||||
if (chapter.Type == "SCHEDULED_LIVESTREAM" && string.IsNullOrEmpty(streamUrl))
|
||||
{
|
||||
_logger.LogDebug("URN {Urn}: Scheduled livestream has no stream URL, fetching fresh data", urn);
|
||||
|
||||
using var freshApiClient = new SRFApiClient(_loggerFactory);
|
||||
var freshMediaComposition = await freshApiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
// Force fresh fetch with short cache duration
|
||||
var freshMediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken, 1).ConfigureAwait(false);
|
||||
|
||||
if (freshMediaComposition?.ChapterList != null && freshMediaComposition.ChapterList.Count > 0)
|
||||
{
|
||||
var freshChapter = freshMediaComposition.ChapterList[0];
|
||||
streamUrl = _streamResolver.GetStreamUrl(freshChapter, config.QualityPreference);
|
||||
streamUrl = _streamResolver.GetStreamUrl(freshChapter, qualityPref);
|
||||
|
||||
if (!string.IsNullOrEmpty(streamUrl))
|
||||
{
|
||||
// Update cache with fresh data
|
||||
_metadataCache.SetMediaComposition(urn, freshMediaComposition);
|
||||
chapter = freshChapter;
|
||||
_logger.LogInformation("URN {Urn}: Got fresh stream URL for scheduled livestream", urn);
|
||||
}
|
||||
@@ -190,7 +168,7 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
_proxyService.RegisterStream(itemIdStr, streamUrl, urn, isLiveStream);
|
||||
|
||||
// Get the server URL for proxy - prefer configured public URL for remote clients
|
||||
var serverUrl = !string.IsNullOrWhiteSpace(config.PublicServerUrl)
|
||||
var serverUrl = config != null && !string.IsNullOrWhiteSpace(config.PublicServerUrl)
|
||||
? config.PublicServerUrl.TrimEnd('/') // Use configured public URL (important for Android/remote clients)
|
||||
: _appHost.GetSmartApiUrl(string.Empty); // Fall back to Jellyfin's smart URL resolution
|
||||
|
||||
@@ -207,7 +185,7 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
"Using proxy URL for item {ItemId}: {ProxyUrl} (PublicServerUrl configured: {IsPublicConfigured})",
|
||||
itemIdStr,
|
||||
proxyUrl,
|
||||
!string.IsNullOrWhiteSpace(config.PublicServerUrl));
|
||||
config != null && !string.IsNullOrWhiteSpace(config.PublicServerUrl));
|
||||
|
||||
// Create media source using proxy URL - enables DirectPlay!
|
||||
var mediaSource = new MediaSourceInfo
|
||||
@@ -311,8 +289,7 @@ public class SRFMediaProvider : IMediaSourceProvider
|
||||
_logger,
|
||||
_proxyService,
|
||||
originalItemId,
|
||||
openToken,
|
||||
_loggerFactory);
|
||||
openToken);
|
||||
|
||||
return await Task.FromResult<ILiveStream>(liveStream).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Plugin.SRFPlay.Api;
|
||||
using Jellyfin.Plugin.SRFPlay.Services;
|
||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -20,27 +19,23 @@ namespace Jellyfin.Plugin.SRFPlay.Providers;
|
||||
public class SRFSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>
|
||||
{
|
||||
private readonly ILogger<SRFSeriesProvider> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly MetadataCache _metadataCache;
|
||||
private readonly IMediaCompositionFetcher _compositionFetcher;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SRFSeriesProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger instance.</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="httpClientFactory">The HTTP client factory.</param>
|
||||
/// <param name="metadataCache">The metadata cache.</param>
|
||||
/// <param name="compositionFetcher">The media composition fetcher.</param>
|
||||
public SRFSeriesProvider(
|
||||
ILogger<SRFSeriesProvider> logger,
|
||||
ILoggerFactory loggerFactory,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
MetadataCache metadataCache)
|
||||
IMediaCompositionFetcher compositionFetcher)
|
||||
{
|
||||
_logger = logger;
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = loggerFactory.CreateLogger<SRFSeriesProvider>();
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_metadataCache = metadataCache;
|
||||
_compositionFetcher = compositionFetcher;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -58,26 +53,7 @@ public class SRFSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>
|
||||
{
|
||||
_logger.LogDebug("Searching for series with URN: {Urn}", urn);
|
||||
|
||||
var config = Plugin.Instance?.Configuration;
|
||||
if (config == null)
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
// Try cache first
|
||||
var mediaComposition = _metadataCache.GetMediaComposition(urn, config.CacheDurationMinutes);
|
||||
|
||||
// If not in cache, fetch from API
|
||||
if (mediaComposition == null)
|
||||
{
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
mediaComposition = await apiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition != null)
|
||||
{
|
||||
_metadataCache.SetMediaComposition(urn, mediaComposition);
|
||||
}
|
||||
}
|
||||
var mediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition?.Show != null)
|
||||
{
|
||||
@@ -125,26 +101,7 @@ public class SRFSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>
|
||||
|
||||
_logger.LogDebug("Fetching metadata for series URN: {Urn}", urn);
|
||||
|
||||
var config = Plugin.Instance?.Configuration;
|
||||
if (config == null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Try cache first
|
||||
var mediaComposition = _metadataCache.GetMediaComposition(urn, config.CacheDurationMinutes);
|
||||
|
||||
// If not in cache, fetch from API
|
||||
if (mediaComposition == null)
|
||||
{
|
||||
using var apiClient = new SRFApiClient(_loggerFactory);
|
||||
mediaComposition = await apiClient.GetMediaCompositionByUrnAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition != null)
|
||||
{
|
||||
_metadataCache.SetMediaComposition(urn, mediaComposition);
|
||||
}
|
||||
}
|
||||
var mediaComposition = await _compositionFetcher.GetMediaCompositionAsync(urn, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mediaComposition?.Show == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user