Rename Clearart to Clearlogo, use png for Clearlogo

This commit is contained in:
Mark McDowall 2023-05-22 10:28:18 -07:00
parent aecc8295c8
commit 349f7cf4c9
2 changed files with 22 additions and 5 deletions

View File

@ -10,7 +10,7 @@ namespace NzbDrone.Core.MediaCover
Fanart = 3, Fanart = 3,
Screenshot = 4, Screenshot = 4,
Headshot = 5, Headshot = 5,
Clearart = 6 Clearlogo = 6
} }
public class MediaCover : IEmbeddedDocument public class MediaCover : IEmbeddedDocument

View File

@ -18,7 +18,7 @@ namespace NzbDrone.Core.MediaCover
public interface IMapCoversToLocal public interface IMapCoversToLocal
{ {
void ConvertToLocalUrls(int seriesId, IEnumerable<MediaCover> covers); void ConvertToLocalUrls(int seriesId, IEnumerable<MediaCover> covers);
string GetCoverPath(int seriesId, MediaCoverTypes mediaCoverTypes, int? height = null); string GetCoverPath(int seriesId, MediaCoverTypes coverType, int? height = null);
} }
public class MediaCoverService : public class MediaCoverService :
@ -63,11 +63,11 @@ namespace NzbDrone.Core.MediaCover
_coverRootFolder = appFolderInfo.GetMediaCoverPath(); _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() : ""; 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<MediaCover> covers) public void ConvertToLocalUrls(int seriesId, IEnumerable<MediaCover> covers)
@ -84,9 +84,14 @@ namespace NzbDrone.Core.MediaCover
{ {
foreach (var mediaCover in covers) foreach (var mediaCover in covers)
{ {
if (mediaCover.CoverType == MediaCoverTypes.Unknown)
{
continue;
}
var filePath = GetCoverPath(seriesId, mediaCover.CoverType); 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)) 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) public void HandleAsync(SeriesUpdatedEvent message)
{ {
var updated = EnsureCovers(message.Series); var updated = EnsureCovers(message.Series);