Browse Source

fix: remove already-played playout items (#2934)

pull/2936/head
Jason Dove 1 month ago committed by GitHub
parent
commit
2b7531ca2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 1
      ErsatzTV.Core/Scheduling/PlayoutBuilder.cs
  3. 6
      ErsatzTV.Core/Scheduling/ScriptedScheduling/ScriptedPlayoutBuilder.cs
  4. 15
      ErsatzTV.Infrastructure/Scheduling/PlayoutTimeShifter.cs

2
CHANGELOG.md

@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- More rarely, content with an embedded subtitle that has stream index zero would create invalid subtitle records
- Both cases will automatically be cleaned up during the next local library scan
- Use `und` language tag with sidecar subtitles that have no language in the file name
- Automatically remove already-played playout items from all on demand channels
- Automatically remove already-played playout items from (continuous) scripted schedules
### Changed
- Upgrade Intel driver in docker containers to support latest Battlemage devices (e.g. B70)

1
ErsatzTV.Core/Scheduling/PlayoutBuilder.cs

@ -301,6 +301,7 @@ public class PlayoutBuilder : IPlayoutBuilder @@ -301,6 +301,7 @@ public class PlayoutBuilder : IPlayoutBuilder
playout.Seed = new Random().Next();
// don't trim start for on demand channels, we want to time shift it all forward
// on-demand channels will trim already-played items in time shifter
if (referenceData.Channel.PlayoutMode is ChannelPlayoutMode.OnDemand)
{
TrimStart = false;

6
ErsatzTV.Core/Scheduling/ScriptedScheduling/ScriptedPlayoutBuilder.cs

@ -108,6 +108,12 @@ public class ScriptedPlayoutBuilder( @@ -108,6 +108,12 @@ public class ScriptedPlayoutBuilder(
playout.Anchor = schedulingEngine.GetAnchor();
// on-demand channels will trim already-played items in time shifter
if (referenceData.Channel.PlayoutMode != ChannelPlayoutMode.OnDemand)
{
schedulingEngine.RemoveBefore(start.AddHours(-4));
}
result = MergeResult(result, schedulingEngine.GetState());
}
catch (OperationCanceledException)

15
ErsatzTV.Infrastructure/Scheduling/PlayoutTimeShifter.cs

@ -72,6 +72,21 @@ public class PlayoutTimeShifter( @@ -72,6 +72,21 @@ public class PlayoutTimeShifter(
playout.OnDemandCheckpoint = playout.Items.Min(p => p.StartOffset);
}
// remove items that have finished before the checkpoint
foreach (DateTimeOffset checkpoint in Optional(playout.OnDemandCheckpoint))
{
DateTime checkpointUtc = checkpoint.UtcDateTime;
int removed = playout.Items.RemoveAll(i => i.Finish < checkpointUtc);
if (removed > 0)
{
logger.LogDebug(
"Removing {Count} played items before shifting playout for channel {Number} - {Name}",
removed,
playout.Channel.Number,
playout.Channel.Name);
}
}
TimeSpan toOffset = now - playout.OnDemandCheckpoint.IfNone(now);
logger.LogDebug(

Loading…
Cancel
Save