From 7b7b866777c419c15459066e57d3bc861539cb92 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 22 May 2023 10:28:18 -0700 Subject: [PATCH] Rename Clearart to Clearlogo, use png for Clearlogo (cherry picked from commit 349f7cf4c934fbf53516f7e92026282750180a16) --- src/NzbDrone.Core/MediaCover/MediaCover.cs | 2 +- .../MediaCover/MediaCoverService.cs | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/MediaCover/MediaCover.cs b/src/NzbDrone.Core/MediaCover/MediaCover.cs index 584650195..0e9025428 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCover.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCover.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.MediaCover Fanart = 3, Screenshot = 4, Headshot = 5, - Clearart = 6 + Clearlogo = 6 } public class MediaCover : MemberwiseEquatable, IEmbeddedDocument diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index 6190e33d4..29bca824b 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.MediaCover Dictionary GetCoverFileInfos(); void ConvertToLocalUrls(int movieId, IEnumerable covers, Dictionary fileInfos = null); void ConvertToLocalUrls(IEnumerable>> items, Dictionary coverFileInfos); - string GetCoverPath(int movieId, MediaCoverTypes mediaCoverTypes, int? height = null); + string GetCoverPath(int movieId, MediaCoverTypes coverType, int? height = null); } public class MediaCoverService : @@ -67,11 +67,11 @@ namespace NzbDrone.Core.MediaCover _coverRootFolder = appFolderInfo.GetMediaCoverPath(); } - public string GetCoverPath(int movieId, MediaCoverTypes coverTypes, int? height = null) + public string GetCoverPath(int movieId, MediaCoverTypes coverType, int? height = null) { var heightSuffix = height.HasValue ? "-" + height.ToString() : ""; - return Path.Combine(GetMovieCoverPath(movieId), coverTypes.ToString().ToLower() + heightSuffix + ".jpg"); + return Path.Combine(GetMovieCoverPath(movieId), coverType.ToString().ToLower() + heightSuffix + GetExtension(coverType)); } public Dictionary GetCoverFileInfos() @@ -101,10 +101,15 @@ namespace NzbDrone.Core.MediaCover { foreach (var mediaCover in covers) { + if (mediaCover.CoverType == MediaCoverTypes.Unknown) + { + continue; + } + var filePath = GetCoverPath(movieId, mediaCover.CoverType); mediaCover.RemoteUrl = mediaCover.Url; - mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + movieId + "/" + mediaCover.CoverType.ToString().ToLower() + ".jpg"; + mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + movieId + "/" + mediaCover.CoverType.ToString().ToLower() + GetExtension(mediaCover.CoverType); FileInfo file; var fileExists = false; @@ -251,6 +256,15 @@ namespace NzbDrone.Core.MediaCover } } + private string GetExtension(MediaCoverTypes coverType) + { + return coverType switch + { + MediaCoverTypes.Clearlogo => ".png", + _ => ".jpg" + }; + } + public void HandleAsync(MovieUpdatedEvent message) { var updated = EnsureCovers(message.Movie);