Browse Source

yaml playout improvements (#2088)

* add stop_before_end

* more yaml playout improvements
pull/2090/head
Jason Dove 2 months ago committed by GitHub
parent
commit
6cc2f1de17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      CHANGELOG.md
  2. 15
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs
  3. 1
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPadToNextHandler.cs
  4. 15
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPadUntilHandler.cs
  5. 3
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutDurationInstruction.cs
  6. 8
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutPadUntilInstruction.cs

10
CHANGELOG.md

@ -36,6 +36,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Synchronize Plex "network" metadata for Plex show libraries - Synchronize Plex "network" metadata for Plex show libraries
- Shows will have new `network` search field - Shows will have new `network` search field
- Episodes will have new `show_network` search field - Episodes will have new `show_network` search field
- YAML playout: add `stop_before_end` setting to `pad_until` and `duration` instructions
- When `stop_before_end: false`, content can run over the desired time before executing the next instruction
- YAML playout: add `offline_tail` setting to `pad_until` instruction
- This can be used to stop primary content before the desired time (`stop_before_end: true` and `offline_tail: false`)
- You can then have a second `pad_until` with the same target time and different content
- YAML playout: make `tomorrow` an expression on `pad_until` instruction
- `true` and `false` still work as normal
- The current time (as a decimal) can also be used in the expression, e.g. `now > 23`
- `now = hours + minutes / 60.0 + seconds / 3600.0`
- So `10:30 AM` would be `10.5`, `10:45 PM` would be `22.75`, etc
### Changed ### Changed
- Allow `Other Video` libraries and `Image` libraries to use the same folders - Allow `Other Video` libraries and `Image` libraries to use the same folders

15
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs

@ -28,6 +28,12 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
return false; return false;
} }
if (duration.StopBeforeEnd == false && duration.OfflineTail)
{
logger.LogError("offline_tail must be false when stop_before_end is false");
return false;
}
DateTimeOffset targetTime = context.CurrentTime.Add(timeSpan); DateTimeOffset targetTime = context.CurrentTime.Add(timeSpan);
Option<IMediaCollectionEnumerator> maybeEnumerator = await GetContentEnumerator( Option<IMediaCollectionEnumerator> maybeEnumerator = await GetContentEnumerator(
@ -49,6 +55,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
instruction.Content, instruction.Content,
duration.Fallback, duration.Fallback,
targetTime, targetTime,
duration.StopBeforeEnd,
duration.DiscardAttempts, duration.DiscardAttempts,
duration.Trim, duration.Trim,
duration.OfflineTail, duration.OfflineTail,
@ -68,6 +75,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
string contentKey, string contentKey,
string fallbackContentKey, string fallbackContentKey,
DateTimeOffset targetTime, DateTimeOffset targetTime,
bool stopBeforeEnd,
int discardAttempts, int discardAttempts,
bool trim, bool trim,
bool offlineTail, bool offlineTail,
@ -97,7 +105,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
//DisableWatermarks = !allowWatermarks //DisableWatermarks = !allowWatermarks
}; };
if (remainingToFill - itemDuration >= TimeSpan.Zero) if (remainingToFill - itemDuration >= TimeSpan.Zero || !stopBeforeEnd)
{ {
context.Playout.Items.Add(playoutItem); context.Playout.Items.Add(playoutItem);
context.AdvanceGuideGroup(); context.AdvanceGuideGroup();
@ -195,6 +203,11 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
} }
} }
if (!stopBeforeEnd)
{
return context.CurrentTime;
}
return offlineTail ? targetTime : context.CurrentTime; return offlineTail ? targetTime : context.CurrentTime;
} }
} }

1
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPadToNextHandler.cs

@ -57,6 +57,7 @@ public class YamlPlayoutPadToNextHandler(EnumeratorCache enumeratorCache) : Yaml
padToNext.Content, padToNext.Content,
padToNext.Fallback, padToNext.Fallback,
targetTime, targetTime,
false,
padToNext.DiscardAttempts, padToNext.DiscardAttempts,
padToNext.Trim, padToNext.Trim,
offlineTail: true, offlineTail: true,

15
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPadUntilHandler.cs

@ -29,7 +29,17 @@ public class YamlPlayoutPadUntilHandler(EnumeratorCache enumeratorCache) : YamlP
if (timeOnly > result) if (timeOnly > result)
{ {
if (padUntil.Tomorrow) var expression = new NCalc.Expression(padUntil.Tomorrow);
expression.EvaluateParameter += (name, e) =>
{
e.Result = name switch
{
"now" => timeOnly.Hour + timeOnly.Minute / 60.0 + timeOnly.Second / 3600.0,
_ => e.Result
};
};
if (expression.Evaluate() as bool? == true)
{ {
// this is wrong when offset changes // this is wrong when offset changes
dayOnly = dayOnly.AddDays(1); dayOnly = dayOnly.AddDays(1);
@ -67,9 +77,10 @@ public class YamlPlayoutPadUntilHandler(EnumeratorCache enumeratorCache) : YamlP
padUntil.Content, padUntil.Content,
padUntil.Fallback, padUntil.Fallback,
targetTime, targetTime,
padUntil.StopBeforeEnd,
padUntil.DiscardAttempts, padUntil.DiscardAttempts,
padUntil.Trim, padUntil.Trim,
offlineTail: true, padUntil.OfflineTail,
GetFillerKind(padUntil), GetFillerKind(padUntil),
padUntil.CustomTitle, padUntil.CustomTitle,
enumerator, enumerator,

3
ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutDurationInstruction.cs

@ -15,4 +15,7 @@ public class YamlPlayoutDurationInstruction : YamlPlayoutInstruction
[YamlMember(Alias = "discard_attempts", ApplyNamingConventions = false)] [YamlMember(Alias = "discard_attempts", ApplyNamingConventions = false)]
public int DiscardAttempts { get; set; } public int DiscardAttempts { get; set; }
[YamlMember(Alias = "stop_before_end", ApplyNamingConventions = false)]
public bool StopBeforeEnd { get; set; } = true;
} }

8
ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutPadUntilInstruction.cs

@ -7,12 +7,18 @@ public class YamlPlayoutPadUntilInstruction : YamlPlayoutInstruction
[YamlMember(Alias = "pad_until", ApplyNamingConventions = false)] [YamlMember(Alias = "pad_until", ApplyNamingConventions = false)]
public string PadUntil { get; set; } public string PadUntil { get; set; }
public bool Tomorrow { get; set; } public string Tomorrow { get; set; }
public bool Trim { get; set; } public bool Trim { get; set; }
[YamlMember(Alias = "offline_tail", ApplyNamingConventions = false)]
public bool OfflineTail { get; set; }
public string Fallback { get; set; } public string Fallback { get; set; }
[YamlMember(Alias = "discard_attempts", ApplyNamingConventions = false)] [YamlMember(Alias = "discard_attempts", ApplyNamingConventions = false)]
public int DiscardAttempts { get; set; } public int DiscardAttempts { get; set; }
[YamlMember(Alias = "stop_before_end", ApplyNamingConventions = false)]
public bool StopBeforeEnd { get; set; } = true;
} }

Loading…
Cancel
Save