Skip to content

Commit

Permalink
Fix(actor): set primary image url (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu authored Jun 10, 2024
1 parent c9fc37b commit 89ef770
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Jellyfin.Plugin.MetaTube/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}
Expand Down

0 comments on commit 89ef770

Please sign in to comment.