using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using LanguageExt; using MediatR; namespace ErsatzTV.Application.FFmpegProfiles.Queries { public class GetFFmpegSettingsHandler : IRequestHandler { private readonly IConfigElementRepository _configElementRepository; public GetFFmpegSettingsHandler(IConfigElementRepository configElementRepository) => _configElementRepository = configElementRepository; public async Task Handle( GetFFmpegSettings request, CancellationToken cancellationToken) { Option ffmpegPath = await _configElementRepository.GetValue(ConfigElementKey.FFmpegPath); Option ffprobePath = await _configElementRepository.GetValue(ConfigElementKey.FFprobePath); Option defaultFFmpegProfileId = await _configElementRepository.GetValue(ConfigElementKey.FFmpegDefaultProfileId); return new FFmpegSettingsViewModel { FFmpegPath = ffmpegPath.IfNone(string.Empty), FFprobePath = ffprobePath.IfNone(string.Empty), DefaultFFmpegProfileId = defaultFFmpegProfileId.IfNone(0) }; } } }