From 349f7cf4c934fbf53516f7e92026282750180a16 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 --- src/NzbDrone.Core/MediaCover/MediaCover.cs | 2 +- .../MediaCover/MediaCoverService.cs | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/MediaCover/MediaCover.cs b/src/NzbDrone.Core/MediaCover/MediaCover.cs index c7b39408b..5bc7257bd 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCover.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCover.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.MediaCover Fanart = 3, Screenshot = 4, Headshot = 5, - Clearart = 6 + Clearlogo = 6 } public class MediaCover : IEmbeddedDocument diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index 37d081899..4e5d76984 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.MediaCover public interface IMapCoversToLocal { void ConvertToLocalUrls(int seriesId, IEnumerable covers); - string GetCoverPath(int seriesId, MediaCoverTypes mediaCoverTypes, int? height = null); + string GetCoverPath(int seriesId, MediaCoverTypes coverType, int? height = null); } public class MediaCoverService : @@ -63,11 +63,11 @@ namespace NzbDrone.Core.MediaCover _coverRootFolder = appFolderInfo.GetMediaCoverPath(); } - public string GetCoverPath(int seriesId, MediaCoverTypes coverTypes, int? height = null) + public string GetCoverPath(int seriesId, MediaCoverTypes coverType, int? height = null) { var heightSuffix = height.HasValue ? "-" + height.ToString() : ""; - return Path.Combine(GetSeriesCoverPath(seriesId), coverTypes.ToString().ToLower() + heightSuffix + ".jpg"); + return Path.Combine(GetSeriesCoverPath(seriesId), coverType.ToString().ToLower() + heightSuffix + GetExtension(coverType)); } public void ConvertToLocalUrls(int seriesId, IEnumerable covers) @@ -84,9 +84,14 @@ namespace NzbDrone.Core.MediaCover { foreach (var mediaCover in covers) { + if (mediaCover.CoverType == MediaCoverTypes.Unknown) + { + continue; + } + var filePath = GetCoverPath(seriesId, mediaCover.CoverType); - mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + seriesId + "/" + mediaCover.CoverType.ToString().ToLower() + ".jpg"; + mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + seriesId + "/" + mediaCover.CoverType.ToString().ToLower() + GetExtension(mediaCover.CoverType); if (_diskProvider.FileExists(filePath)) { @@ -213,6 +218,18 @@ namespace NzbDrone.Core.MediaCover } } + private string GetExtension(MediaCoverTypes coverType) + { + switch (coverType) + { + default: + return ".jpg"; + + case MediaCoverTypes.Clearlogo: + return ".png"; + } + } + public void HandleAsync(SeriesUpdatedEvent message) { var updated = EnsureCovers(message.Series);