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.
49 lines
1.7 KiB
49 lines
1.7 KiB
using ErsatzTV.Core.Api.Channels; |
|
using ErsatzTV.Core.Domain; |
|
|
|
namespace ErsatzTV.Application.Channels; |
|
|
|
internal static class Mapper |
|
{ |
|
internal static ChannelViewModel ProjectToViewModel(Channel channel) => |
|
new( |
|
channel.Id, |
|
channel.Number, |
|
channel.Name, |
|
channel.Group, |
|
channel.Categories, |
|
channel.FFmpegProfileId, |
|
GetLogo(channel), |
|
channel.PreferredAudioLanguageCode, |
|
channel.PreferredAudioTitle, |
|
channel.StreamingMode, |
|
channel.WatermarkId, |
|
channel.FallbackFillerId, |
|
channel.Playouts?.Count ?? 0, |
|
channel.PreferredSubtitleLanguageCode, |
|
channel.SubtitleMode, |
|
channel.MusicVideoCreditsMode); |
|
|
|
internal static ChannelResponseModel ProjectToResponseModel(Channel channel) => |
|
new( |
|
channel.Id, |
|
channel.Number, |
|
channel.Name, |
|
channel.FFmpegProfile.Name, |
|
channel.PreferredAudioLanguageCode, |
|
GetStreamingMode(channel)); |
|
|
|
private static string GetLogo(Channel channel) => |
|
Optional(channel.Artwork.FirstOrDefault(a => a.ArtworkKind == ArtworkKind.Logo)) |
|
.Match(a => a.Path, string.Empty); |
|
|
|
private static string GetStreamingMode(Channel channel) => |
|
channel.StreamingMode switch |
|
{ |
|
StreamingMode.TransportStream => "MPEG-TS (Legacy)", |
|
StreamingMode.TransportStreamHybrid => "MPEG-TS", |
|
StreamingMode.HttpLiveStreamingDirect => "HLS Direct", |
|
StreamingMode.HttpLiveStreamingSegmenter => "HLS Segmenter", |
|
_ => throw new ArgumentOutOfRangeException() |
|
}; |
|
}
|
|
|