mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-03 13:44:22 -04:00
Handle empty image lists gracefully in SplashscreenPostScanTask (#13498)
The current linq will just throw when there is no image candidates. Just pass empty lists to `CreateSplashscreen` as this case is already handled there.
This commit is contained in:
parent
075fec6fc6
commit
7a5a4ad7da
@ -43,14 +43,26 @@ public class SplashscreenPostScanTask : ILibraryPostScanTask
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var posters = GetItemsWithImageType(ImageType.Primary).Select(x => x.GetImages(ImageType.Primary).First().Path).ToList();
|
var posters = GetItemsWithImageType(ImageType.Primary)
|
||||||
var backdrops = GetItemsWithImageType(ImageType.Thumb).Select(x => x.GetImages(ImageType.Thumb).First().Path).ToList();
|
.Select(x => x.GetImages(ImageType.Primary).FirstOrDefault()?.Path)
|
||||||
|
.Where(path => !string.IsNullOrEmpty(path))
|
||||||
|
.Select(path => path!)
|
||||||
|
.ToList();
|
||||||
|
var backdrops = GetItemsWithImageType(ImageType.Thumb)
|
||||||
|
.Select(x => x.GetImages(ImageType.Thumb).FirstOrDefault()?.Path)
|
||||||
|
.Where(path => !string.IsNullOrEmpty(path))
|
||||||
|
.Select(path => path!)
|
||||||
|
.ToList();
|
||||||
if (backdrops.Count == 0)
|
if (backdrops.Count == 0)
|
||||||
{
|
{
|
||||||
// Thumb images fit better because they include the title in the image but are not provided with TMDb.
|
// Thumb images fit better because they include the title in the image but are not provided with TMDb.
|
||||||
// Using backdrops as a fallback to generate an image at all
|
// Using backdrops as a fallback to generate an image at all
|
||||||
_logger.LogDebug("No thumb images found. Using backdrops to generate splashscreen");
|
_logger.LogDebug("No thumb images found. Using backdrops to generate splashscreen");
|
||||||
backdrops = GetItemsWithImageType(ImageType.Backdrop).Select(x => x.GetImages(ImageType.Backdrop).First().Path).ToList();
|
backdrops = GetItemsWithImageType(ImageType.Backdrop)
|
||||||
|
.Select(x => x.GetImages(ImageType.Backdrop).FirstOrDefault()?.Path)
|
||||||
|
.Where(path => !string.IsNullOrEmpty(path))
|
||||||
|
.Select(path => path!)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
_imageEncoder.CreateSplashscreen(posters, backdrops);
|
_imageEncoder.CreateSplashscreen(posters, backdrops);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user