mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.0 KiB
29 lines
1.0 KiB
using ErsatzTV.Core.Domain; |
|
using ErsatzTV.FFmpeg.Capabilities; |
|
using ErsatzTV.Infrastructure.Data; |
|
using ErsatzTV.Infrastructure.Extensions; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Application.FFmpeg; |
|
|
|
public class RefreshFFmpegCapabilitiesHandler( |
|
IDbContextFactory<TvContext> dbContextFactory, |
|
IHardwareCapabilitiesFactory hardwareCapabilitiesFactory) |
|
: IRequestHandler<RefreshFFmpegCapabilities> |
|
{ |
|
public async Task Handle(RefreshFFmpegCapabilities request, CancellationToken cancellationToken) |
|
{ |
|
hardwareCapabilitiesFactory.ClearCache(); |
|
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
|
|
|
Option<string> maybeFFmpegPath = await dbContext.ConfigElements |
|
.GetValue<string>(ConfigElementKey.FFmpegPath, cancellationToken) |
|
.FilterT(File.Exists); |
|
|
|
foreach (string ffmpegPath in maybeFFmpegPath) |
|
{ |
|
_ = await hardwareCapabilitiesFactory.GetFFmpegCapabilities(ffmpegPath); |
|
} |
|
} |
|
}
|
|
|