Merge pull request #7894 from crobibero/search-hints

This commit is contained in:
Cody Robibero 2022-06-13 16:27:16 -06:00 committed by GitHub
commit 0f75f17736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -6,6 +6,7 @@ using System.Linq;
using Jellyfin.Api.Constants;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@ -187,7 +188,7 @@ namespace Jellyfin.Api.Controllers
result.AlbumArtist = album.AlbumArtist;
break;
case Audio song:
result.AlbumArtist = song.AlbumArtists?[0];
result.AlbumArtist = song.AlbumArtists?.FirstOrDefault();
result.Artists = song.Artists;
MusicAlbum musicAlbum = song.AlbumEntity;

View File

@ -57,5 +57,21 @@ namespace Jellyfin.Extensions
return -1;
}
/// <summary>
/// Get the first or default item from a list.
/// </summary>
/// <param name="source">The source list.</param>
/// <typeparam name="T">The type of item.</typeparam>
/// <returns>The first item or default if list is empty.</returns>
public static T? FirstOrDefault<T>(this IReadOnlyList<T>? source)
{
if (source is null || source.Count == 0)
{
return default;
}
return source[0];
}
}
}