add yaml playout sequences (#1826)
This commit is contained in:
@@ -4,6 +4,8 @@ public class YamlPlayoutDefinition
|
||||
{
|
||||
public List<YamlPlayoutContentItem> Content { get; set; } = [];
|
||||
|
||||
public List<YamlPlayoutSequenceItem> Sequence { get; set; } = [];
|
||||
|
||||
public List<YamlPlayoutInstruction> Reset { get; set; } = [];
|
||||
|
||||
public List<YamlPlayoutInstruction> Playout { get; set; } = [];
|
||||
|
||||
@@ -10,4 +10,7 @@ public class YamlPlayoutInstruction
|
||||
|
||||
[YamlMember(Alias = "filler_kind", ApplyNamingConventions = false)]
|
||||
public string FillerKind { get; set; }
|
||||
|
||||
[YamlIgnore]
|
||||
public string SequenceKey { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Models;
|
||||
|
||||
public class YamlPlayoutSequenceInstruction : YamlPlayoutInstruction
|
||||
{
|
||||
public string Sequence { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Models;
|
||||
|
||||
public class YamlPlayoutSequenceItem
|
||||
{
|
||||
public string Key { get; set; }
|
||||
|
||||
public List<YamlPlayoutInstruction> Items { get; set; } = [];
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Immutable;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Interfaces.Metadata;
|
||||
using ErsatzTV.Core.Interfaces.Repositories;
|
||||
@@ -78,6 +79,8 @@ public class YamlPlayoutBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
FlattenSequences(context);
|
||||
|
||||
// handle all playout instructions
|
||||
while (context.CurrentTime < finish)
|
||||
{
|
||||
@@ -112,6 +115,38 @@ public class YamlPlayoutBuilder(
|
||||
.GetValue<int>(ConfigElementKey.PlayoutDaysToBuild)
|
||||
.IfNoneAsync(2);
|
||||
|
||||
private static void FlattenSequences(YamlPlayoutContext context)
|
||||
{
|
||||
var rawInstructions = context.Definition.Playout.ToImmutableList();
|
||||
context.Definition.Playout.Clear();
|
||||
|
||||
foreach (YamlPlayoutInstruction instruction in rawInstructions)
|
||||
{
|
||||
switch (instruction)
|
||||
{
|
||||
case YamlPlayoutSequenceInstruction sequenceInstruction:
|
||||
IEnumerable<YamlPlayoutInstruction> sequenceInstructions = context.Definition.Sequence
|
||||
.Filter(s => s.Key == sequenceInstruction.Sequence)
|
||||
.HeadOrNone()
|
||||
.Map(s => s.Items)
|
||||
.Flatten();
|
||||
|
||||
// insert all instructions from the sequence
|
||||
foreach (YamlPlayoutInstruction i in sequenceInstructions)
|
||||
{
|
||||
// maybe used for shuffling later?
|
||||
i.SequenceKey = sequenceInstruction.Sequence;
|
||||
|
||||
context.Definition.Playout.Add(i);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
context.Definition.Playout.Add(instruction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Option<IYamlPlayoutHandler> GetHandlerForInstruction(
|
||||
Dictionary<YamlPlayoutInstruction, IYamlPlayoutHandler> handlers,
|
||||
EnumeratorCache enumeratorCache,
|
||||
@@ -171,6 +206,7 @@ public class YamlPlayoutBuilder(
|
||||
{ "new_epg_group", typeof(YamlPlayoutNewEpgGroupInstruction) },
|
||||
{ "pad_to_next", typeof(YamlPlayoutPadToNextInstruction) },
|
||||
{ "repeat", typeof(YamlPlayoutRepeatInstruction) },
|
||||
{ "sequence", typeof(YamlPlayoutSequenceInstruction) },
|
||||
{ "skip_items", typeof(YamlPlayoutSkipItemsInstruction) },
|
||||
{ "wait_until", typeof(YamlPlayoutWaitUntilInstruction) }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user