2024-11-05 19:39:32 -06:00
|
|
|
|
using LANCommander.Server.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Server.Jobs.Background
|
|
|
|
|
|
{
|
|
|
|
|
|
public class GenerateThumbnailsJob : BaseBackgroundJob
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly MediaService MediaService;
|
|
|
|
|
|
|
|
|
|
|
|
public GenerateThumbnailsJob(
|
|
|
|
|
|
ILogger<GenerateThumbnailsJob> logger,
|
|
|
|
|
|
MediaService mediaService) : base(logger)
|
|
|
|
|
|
{
|
|
|
|
|
|
MediaService = mediaService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync()
|
|
|
|
|
|
{
|
2024-11-12 18:32:46 -06:00
|
|
|
|
var allMedia = await MediaService.GetAsync();
|
2024-11-05 19:39:32 -06:00
|
|
|
|
|
|
|
|
|
|
foreach (var media in allMedia)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!MediaService.ThumbnailExists(media))
|
|
|
|
|
|
await MediaService.GenerateThumbnailAsync(media);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|