Enhance logging in RefreshShowEpisodesMetadataCommandHandler and TmdbMetadataProvider for image retrieval failures
ci / build-backend (push) Successful in 5m2s
ci / build-frontend (push) Successful in 55s
ci / tests (push) Successful in 1m44s
ci / sonar (push) Successful in 4m31s

Updated the RefreshShowEpisodesMetadataCommandHandler to include logging for scenarios where episode still images are not retrieved successfully. Introduced warning logs for missing still URLs and download failures, improving traceability. Additionally, modified the TmdbMetadataProvider to implement a fallback mechanism for episode still images, ensuring that appropriate imagery is displayed even when localized images are unavailable. Updated related tests to verify the correct behavior of these logging enhancements and fallback logic.
This commit is contained in:
Leonid Pershin
2026-07-30 02:08:50 +03:00
parent 3fecd81333
commit 5032614773
5 changed files with 73 additions and 14 deletions
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Metadata;
@@ -39,7 +40,8 @@ public class RefreshEpisodesTests
db,
resolver,
downloader ?? Substitute.For<IImageDownloader>(),
store ?? Substitute.For<IImageStore>()
store ?? Substitute.For<IImageStore>(),
NullLogger<RefreshShowEpisodesMetadataCommandHandler>.Instance
);
/// <summary>Сериал с привязкой к источнику и одной серией на готовом ассете.</summary>
@@ -146,6 +146,26 @@ public class TmdbMetadataProviderTests
Assert.EndsWith("/neutral.jpg", show?.PosterUrl);
}
/// <summary>Кадр серии — та же история, что и с постером шоу: под русский язык его часто нет.</summary>
[Fact]
public async Task GetEpisode_WithoutLocalizedStill_FallsBackToNeutralOne()
{
var http = new FakeHttpClientFactory(url =>
FakeHttpClientFactory.Ok(
url.Contains("language=", StringComparison.Ordinal)
? """{"name":"Серия"}"""
: """{"name":"Серия","still_path":"/neutral.jpg"}"""
)
);
var episode = await Provider(http).GetEpisodeAsync("9", 2, 5, CancellationToken.None);
Assert.Equal(2, http.Urls.Count);
Assert.DoesNotContain("language=", http.LastUrl);
Assert.Contains("/tv/9/season/2/episode/5", http.LastUrl);
Assert.EndsWith("/neutral.jpg", episode?.StillUrl);
}
[Fact]
public async Task GetShow_Movie_FallsBackToAnyReleaseCertification()
{