More Metadata Stuff (#3537)

This commit is contained in:
Joe Milazzo 2025-02-08 15:37:12 -06:00 committed by GitHub
parent 8d3dcc637e
commit 53b13da0c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 4123 additions and 129 deletions

View file

@ -28,7 +28,8 @@ public interface ICoverDbService
Task<string> DownloadPublisherImageAsync(string publisherName, EncodeFormat encodeFormat);
Task<string?> DownloadPersonImageAsync(Person person, EncodeFormat encodeFormat);
Task<string?> DownloadPersonImageAsync(Person person, EncodeFormat encodeFormat, string url);
Task SetPersonCoverImage(Person person, string url, bool fromBase64 = true);
Task SetPersonCoverByUrl(Person person, string url, bool fromBase64 = true);
Task SetSeriesCoverByUrl(Series series, string url, bool fromBase64 = true);
}
@ -460,7 +461,8 @@ public class CoverDbService : ICoverDbService
return null;
}
public async Task SetPersonCoverImage(Person person, string url, bool fromBase64 = true)
public async Task SetPersonCoverByUrl(Person person, string url, bool fromBase64 = true)
{
if (!string.IsNullOrEmpty(url))
{
@ -490,6 +492,42 @@ public class CoverDbService : ICoverDbService
}
}
/// <summary>
/// Sets the series cover by url
/// </summary>
/// <param name="series"></param>
/// <param name="url"></param>
/// <param name="fromBase64"></param>
public async Task SetSeriesCoverByUrl(Series series, string url, bool fromBase64 = true)
{
if (!string.IsNullOrEmpty(url))
{
var filePath = await CreateThumbnail(url, $"{ImageService.GetSeriesFormat(series.Id)}", fromBase64);
if (!string.IsNullOrEmpty(filePath))
{
series.CoverImage = filePath;
series.CoverImageLocked = true;
_imageService.UpdateColorScape(series);
_unitOfWork.SeriesRepository.Update(series);
}
}
else
{
series.CoverImage = string.Empty;
series.CoverImageLocked = false;
_imageService.UpdateColorScape(series);
_unitOfWork.SeriesRepository.Update(series);
}
if (_unitOfWork.HasChanges())
{
await _unitOfWork.CommitAsync();
await _eventHub.SendMessageAsync(MessageFactory.CoverUpdate,
MessageFactory.CoverUpdateEvent(series.Id, MessageFactoryEntityTypes.Series), false);
}
}
private async Task<string> CreateThumbnail(string url, string filename, bool fromBase64 = true)
{
var settings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();