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.
40 lines
1.9 KiB
40 lines
1.9 KiB
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<GetFFmpegSettings, FFmpegSettingsViewModel> |
|
{ |
|
private readonly IConfigElementRepository _configElementRepository; |
|
|
|
public GetFFmpegSettingsHandler(IConfigElementRepository configElementRepository) => |
|
_configElementRepository = configElementRepository; |
|
|
|
public async Task<FFmpegSettingsViewModel> Handle( |
|
GetFFmpegSettings request, |
|
CancellationToken cancellationToken) |
|
{ |
|
Option<string> ffmpegPath = await _configElementRepository.GetValue<string>(ConfigElementKey.FFmpegPath); |
|
Option<string> ffprobePath = await _configElementRepository.GetValue<string>(ConfigElementKey.FFprobePath); |
|
Option<int> defaultFFmpegProfileId = |
|
await _configElementRepository.GetValue<int>(ConfigElementKey.FFmpegDefaultProfileId); |
|
Option<bool> saveReports = |
|
await _configElementRepository.GetValue<bool>(ConfigElementKey.FFmpegSaveReports); |
|
Option<string> preferredLanguageCode = |
|
await _configElementRepository.GetValue<string>(ConfigElementKey.FFmpegPreferredLanguageCode); |
|
|
|
return new FFmpegSettingsViewModel |
|
{ |
|
FFmpegPath = await ffmpegPath.IfNoneAsync(string.Empty), |
|
FFprobePath = await ffprobePath.IfNoneAsync(string.Empty), |
|
DefaultFFmpegProfileId = await defaultFFmpegProfileId.IfNoneAsync(0), |
|
SaveReports = await saveReports.IfNoneAsync(false), |
|
PreferredLanguageCode = await preferredLanguageCode.IfNoneAsync("eng") |
|
}; |
|
} |
|
} |
|
}
|
|
|