From 89ef770bcfc764e5456c9cc83a7f6b06e1eba73f Mon Sep 17 00:00:00 2001 From: Jason Lyu Date: Mon, 10 Jun 2024 16:00:51 -0400 Subject: [PATCH] Fix(actor): set primary image url (#340) --- .../Providers/MovieProvider.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Plugin.MetaTube/Providers/MovieProvider.cs b/Jellyfin.Plugin.MetaTube/Providers/MovieProvider.cs index 751bb2b..8341433 100644 --- a/Jellyfin.Plugin.MetaTube/Providers/MovieProvider.cs +++ b/Jellyfin.Plugin.MetaTube/Providers/MovieProvider.cs @@ -248,16 +248,27 @@ private async Task SetActorImageUrl(PersonInfo actor, CancellationToken cancella try { var results = await ApiClient.SearchActorAsync(actor.Name, cancellationToken); - // Use the first result as the primary actor selection. - if (results.Any()) + if (results?.Any() != true) { - actor.ImageUrl = results.First().Images?.FirstOrDefault(); - actor.SetPid(Name, results.First().Provider, results.First().Id); + Logger.Warn("Actor not found: {0}", actor.Name); + return; + } + + { + // Use the first result as the primary actor selection. + var firstResult = results.First(); + if (firstResult.Images?.Any() == true) + actor.ImageUrl = ApiClient.GetPrimaryImageApiUrl( + firstResult.Provider, firstResult.Id, firstResult.Images.First(), 0.5, true); + actor.SetPid(Name, firstResult.Provider, firstResult.Id); } // Use the GFriends to update the actor profile image. foreach (var result in results.Where(result => result.Provider == GFriends && result.Images?.Any() == true)) - actor.ImageUrl = result.Images.First(); + { + actor.ImageUrl = ApiClient.GetPrimaryImageApiUrl( + result.Provider, result.Id, result.Images.First(), 0.5, true); + } } catch (Exception e) { @@ -272,7 +283,7 @@ private async Task ConvertToRealActorNames(MovieSearchResult m, CancellationToke try { var searchResults = await ApiClient.SearchMovieAsync(m.Id, AvBase, cancellationToken); - if (!searchResults.Any()) + if (searchResults?.Any() != true) { Logger.Warn("Movie not found on AVBASE: {0}", m.Id); }