Browse Source

add yaml playout rewind instruction (#2243)

pull/2244/head
Jason Dove 1 year ago committed by GitHub
parent
commit
aa3bd3b750
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .editorconfig
  2. 9
      CHANGELOG.md
  3. 30
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutRewindHandler.cs
  4. 6
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutRewindInstruction.cs
  5. 2
      ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs
  6. 9
      ErsatzTV/Resources/yaml-playout.schema.json

2
.editorconfig

@ -31,7 +31,7 @@ csharp_style_expression_bodied_constructors=true:none
csharp_style_expression_bodied_methods=true:none csharp_style_expression_bodied_methods=true:none
csharp_style_expression_bodied_properties=true:suggestion csharp_style_expression_bodied_properties=true:suggestion
csharp_style_var_elsewhere=false:suggestion csharp_style_var_elsewhere=false:suggestion
csharp_style_var_for_built_in_types=false:suggestion csharp_style_var_for_built_in_types=false:none
csharp_style_var_when_type_is_apparent=true:suggestion csharp_style_var_when_type_is_apparent=true:suggestion
dotnet_naming_rule.local_constants_rule.severity=warning dotnet_naming_rule.local_constants_rule.severity=warning
dotnet_naming_rule.local_constants_rule.style=all_upper_style dotnet_naming_rule.local_constants_rule.style=all_upper_style

9
CHANGELOG.md

@ -19,9 +19,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- With value of `true` and `sequence` property, will enable automatic post-roll for all content in the playout to the sequence with the provided key - With value of `true` and `sequence` property, will enable automatic post-roll for all content in the playout to the sequence with the provided key
- With value of `false`, will disable automatic post-roll in the playout - With value of `false`, will disable automatic post-roll in the playout
- YAML playout: add `mid_roll` instruction to enable and disable a mid-roll sequence - YAML playout: add `mid_roll` instruction to enable and disable a mid-roll sequence
- With value of `true` and `sequence` property, will enable automatic mid-roll for (`count` and `all`) content in the playout to the sequence with the provided key - With value of `true` and `sequence` property, will enable automatic mid-roll for (`count` and `all`) content in the playout to the sequence with the provided key
- With value of `false`, will disable automatic post-roll in the playout - With value of `false`, will disable automatic post-roll in the playout
- `expression` can be used to influence which chapters are selected for mid roll (same as in filler preset) - `expression` can be used to influence which chapters are selected for mid roll (same as in filler preset)
- YAML playout: add `rewind` instruction to set start of playout relative to the current time
- Value should be formatted as `HH:MM:SS` e.g. `00:05:30` for 5 minutes 30 seconds (before now)
- This is instruction is mostly useful for debugging transitions, and can only be used as a reset instruction
- Add YAML playout validation (using JSON Schema) - Add YAML playout validation (using JSON Schema)
- Invalid YAML playout definitions will fail to build and will log validation failures as warnings - Invalid YAML playout definitions will fail to build and will log validation failures as warnings
- `content` is fully validated - `content` is fully validated

30
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutRewindHandler.cs

@ -0,0 +1,30 @@
using ErsatzTV.Core.Scheduling.YamlScheduling.Models;
using Microsoft.Extensions.Logging;
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Handlers;
public class YamlPlayoutRewindHandler : IYamlPlayoutHandler
{
public bool Reset => true;
public Task<bool> Handle(
YamlPlayoutContext context,
YamlPlayoutInstruction instruction,
PlayoutBuildMode mode,
Func<string, Task> executeSequence,
ILogger<YamlPlayoutBuilder> logger,
CancellationToken cancellationToken)
{
if (instruction is not YamlPlayoutRewindInstruction rewind)
{
return Task.FromResult(false);
}
if (TimeSpan.TryParse(rewind.Rewind ?? string.Empty, out TimeSpan amount))
{
context.CurrentTime -= amount;
}
return Task.FromResult(true);
}
}

6
ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutRewindInstruction.cs

@ -0,0 +1,6 @@
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Models;
public class YamlPlayoutRewindInstruction : YamlPlayoutInstruction
{
public string Rewind { get; set; }
}

2
ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs

@ -349,6 +349,7 @@ public class YamlPlayoutBuilder(
YamlPlayoutSkipItemsInstruction => new YamlPlayoutSkipItemsHandler(enumeratorCache), YamlPlayoutSkipItemsInstruction => new YamlPlayoutSkipItemsHandler(enumeratorCache),
YamlPlayoutSkipToItemInstruction => new YamlPlayoutSkipToItemHandler(enumeratorCache), YamlPlayoutSkipToItemInstruction => new YamlPlayoutSkipToItemHandler(enumeratorCache),
YamlPlayoutRewindInstruction => new YamlPlayoutRewindHandler(),
// content handlers // content handlers
YamlPlayoutAllInstruction => new YamlPlayoutAllHandler(enumeratorCache), YamlPlayoutAllInstruction => new YamlPlayoutAllHandler(enumeratorCache),
@ -408,6 +409,7 @@ public class YamlPlayoutBuilder(
{ "post_roll", typeof(YamlPostRollInstruction) }, { "post_roll", typeof(YamlPostRollInstruction) },
{ "mid_roll", typeof(YamlMidRollInstruction) }, { "mid_roll", typeof(YamlMidRollInstruction) },
{ "repeat", typeof(YamlPlayoutRepeatInstruction) }, { "repeat", typeof(YamlPlayoutRepeatInstruction) },
{ "rewind", typeof(YamlPlayoutRewindInstruction) },
{ "sequence", typeof(YamlPlayoutSequenceInstruction) }, { "sequence", typeof(YamlPlayoutSequenceInstruction) },
{ "shuffle_sequence", typeof(YamlPlayoutShuffleSequenceInstruction) }, { "shuffle_sequence", typeof(YamlPlayoutShuffleSequenceInstruction) },
{ "skip_items", typeof(YamlPlayoutSkipItemsInstruction) }, { "skip_items", typeof(YamlPlayoutSkipItemsInstruction) },

9
ErsatzTV/Resources/yaml-playout.schema.json

@ -62,6 +62,7 @@
"type": "array", "type": "array",
"items": { "items": {
"oneOf": [ "oneOf": [
{ "$ref": "#/$defs/control/rewindInstruction" },
{ "$ref": "#/$defs/control/skipItemsInstruction" }, { "$ref": "#/$defs/control/skipItemsInstruction" },
{ "$ref": "#/$defs/control/skipToItemInstruction" }, { "$ref": "#/$defs/control/skipToItemInstruction" },
{ "$ref": "#/$defs/control/waitUntilInstruction" } { "$ref": "#/$defs/control/waitUntilInstruction" }
@ -284,6 +285,14 @@
} }
}, },
"control": { "control": {
"rewindInstruction": {
"type": "object",
"properties": {
"rewind": { "type": "string" }
},
"required": [ "rewind" ],
"additionalProperties": false
},
"epgGroupInstruction": { "epgGroupInstruction": {
"type": "object", "type": "object",
"properties": { "properties": {

Loading…
Cancel
Save