Merge pull request #12055 from Shadowghost/fix-season-backdrops

Fix season backdrops
This commit is contained in:
Bond-009 2024-06-24 22:41:57 +02:00 committed by GitHub
commit 2266a00337
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 18 deletions

View File

@ -427,13 +427,15 @@ namespace MediaBrowser.Providers.Manager
if (type == ImageType.Backdrop && saveLocally)
{
if (season is not null && season.IndexNumber.HasValue)
if (season is not null
&& season.IndexNumber.HasValue
&& (imageIndex is null || imageIndex == 0))
{
var seriesFolder = season.SeriesPath;
var seasonMarker = season.IndexNumber.Value == 0
? "-specials"
: season.IndexNumber.Value.ToString("00", CultureInfo.InvariantCulture);
? "-specials"
: season.IndexNumber.Value.ToString("00", CultureInfo.InvariantCulture);
var imageFilename = "season" + seasonMarker + "-fanart" + extension;

View File

@ -159,7 +159,7 @@ namespace MediaBrowser.Providers.Manager
}
}
// only delete existing multi-images if new ones were added
// Only delete existing multi-images if new ones were added
if (oldBackdropImages.Length > 0 && oldBackdropImages.Length < item.GetImages(ImageType.Backdrop).Count())
{
PruneImages(item, oldBackdropImages);
@ -422,14 +422,11 @@ namespace MediaBrowser.Providers.Manager
{
var changed = item.ValidateImages();
var foundImageTypes = new List<ImageType>();
for (var i = 0; i < _singularImages.Length; i++)
{
var type = _singularImages[i];
var image = GetFirstLocalImageInfoByType(images, type);
// Only use local images if we are not replacing and saving
if (image is not null && !(item.IsSaveLocalMetadataEnabled() && refreshOptions.ReplaceAllImages))
if (image is not null)
{
var currentImage = item.GetImageInfo(type, 0);
// if image file is stored with media, don't replace that later

View File

@ -100,21 +100,29 @@ namespace MediaBrowser.Providers.Manager
}
}
// Start by validating images
var localImagesFailed = false;
var allImageProviders = ProviderManager.GetImageProviders(item, refreshOptions).ToList();
try
// Only validate already registered images if we are replacing and saving locally
if (item.IsSaveLocalMetadataEnabled() && refreshOptions.ReplaceAllImages)
{
// Always validate images and check for new locally stored ones.
if (ImageProvider.ValidateImages(item, allImageProviders.OfType<ILocalImageProvider>(), refreshOptions))
{
updateType |= ItemUpdateType.ImageUpdate;
}
item.ValidateImages();
}
catch (Exception ex)
else
{
localImagesFailed = true;
Logger.LogError(ex, "Error validating images for {Item}", item.Path ?? item.Name ?? "Unknown name");
// Run full image validation and register new local images
try
{
if (ImageProvider.ValidateImages(item, allImageProviders.OfType<ILocalImageProvider>(), refreshOptions))
{
updateType |= ItemUpdateType.ImageUpdate;
}
}
catch (Exception ex)
{
localImagesFailed = true;
Logger.LogError(ex, "Error validating images for {Item}", item.Path ?? item.Name ?? "Unknown name");
}
}
var metadataResult = new MetadataResult<TItemType>