diff --git a/CHANGELOG.md b/CHANGELOG.md index daa3037c..372e7f64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix selecting audio stream with preferred title - Fix synchronizing Plex collections - If this breaks collection sync for you, you will need to update your Plex server +- Fix guide group generation for `duration` YAML instructions ## [0.8.8-beta] - 2024-09-19 ### Added diff --git a/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs b/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs index 1a94407d..1a0ae630 100644 --- a/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs +++ b/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs @@ -49,7 +49,7 @@ public class YamlPlayoutAllHandler(EnumeratorCache enumeratorCache) : YamlPlayou //PreferredAudioTitle = scheduleItem.PreferredAudioTitle, //PreferredSubtitleLanguageCode = scheduleItem.PreferredSubtitleLanguageCode, //SubtitleMode = scheduleItem.SubtitleMode - GuideGroup = context.NextGuideGroup() + GuideGroup = context.PeekNextGuideGroup() //GuideStart = effectiveBlock.Start.UtcDateTime, //GuideFinish = blockFinish.UtcDateTime, //BlockKey = JsonConvert.SerializeObject(effectiveBlock.BlockKey), @@ -58,6 +58,7 @@ public class YamlPlayoutAllHandler(EnumeratorCache enumeratorCache) : YamlPlayou }; context.Playout.Items.Add(playoutItem); + context.AdvanceGuideGroup(); // create history record Option maybeHistory = GetHistoryForItem( diff --git a/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs b/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs index 8b5679b8..9203c58c 100644 --- a/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs +++ b/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs @@ -49,7 +49,7 @@ public class YamlPlayoutCountHandler(EnumeratorCache enumeratorCache) : YamlPlay //PreferredAudioTitle = scheduleItem.PreferredAudioTitle, //PreferredSubtitleLanguageCode = scheduleItem.PreferredSubtitleLanguageCode, //SubtitleMode = scheduleItem.SubtitleMode - GuideGroup = context.NextGuideGroup() + GuideGroup = context.PeekNextGuideGroup() //GuideStart = effectiveBlock.Start.UtcDateTime, //GuideFinish = blockFinish.UtcDateTime, //BlockKey = JsonConvert.SerializeObject(effectiveBlock.BlockKey), @@ -58,6 +58,7 @@ public class YamlPlayoutCountHandler(EnumeratorCache enumeratorCache) : YamlPlay }; context.Playout.Items.Add(playoutItem); + context.AdvanceGuideGroup(); // create history record Option maybeHistory = GetHistoryForItem( diff --git a/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs b/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs index 35778ada..dda79095 100644 --- a/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs +++ b/ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs @@ -91,7 +91,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP Finish = context.CurrentTime.UtcDateTime + itemDuration, InPoint = TimeSpan.Zero, OutPoint = itemDuration, - GuideGroup = context.NextGuideGroup(), + GuideGroup = context.PeekNextGuideGroup(), FillerKind = fillerKind, CustomTitle = string.IsNullOrWhiteSpace(customTitle) ? null : customTitle //DisableWatermarks = !allowWatermarks @@ -100,6 +100,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP if (remainingToFill - itemDuration >= TimeSpan.Zero) { context.Playout.Items.Add(playoutItem); + context.AdvanceGuideGroup(); // create history record Option maybeHistory = GetHistoryForItem( @@ -132,6 +133,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP playoutItem.OutPoint = playoutItem.Finish - playoutItem.Start; context.Playout.Items.Add(playoutItem); + context.AdvanceGuideGroup(); // create history record Option maybeHistory = GetHistoryForItem( diff --git a/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs b/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs index b773ddc2..ca4efc1a 100644 --- a/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs +++ b/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs @@ -170,9 +170,11 @@ public class YamlPlayoutBuilder( { NextStart = maxTime, NextInstructionIndex = context.InstructionIndex, - NextGuideGroup = context.NextGuideGroup() + NextGuideGroup = context.PeekNextGuideGroup() }; + context.AdvanceGuideGroup(); + // logger.LogDebug( // "Saving yaml context at {Start}, instruction {Instruction}", // maxTime, diff --git a/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs b/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs index 2e4f1794..987bcc36 100644 --- a/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs +++ b/ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs @@ -28,27 +28,41 @@ public class YamlPlayoutContext(Playout playout, YamlPlayoutDefinition definitio public bool VisitedAll => _visitedInstructions.Count >= Definition.Playout.Count; - public int NextGuideGroup() + public int PeekNextGuideGroup() { if (_guideGroupLocked) { return _guideGroup; } + int result = _guideGroup + 1; + if (result > 1000) + { + result = 1; + } + + return result; + } + + public void AdvanceGuideGroup() + { + if (_guideGroupLocked) + { + return; + } + _guideGroup++; if (_guideGroup > 1000) { _guideGroup = 1; } - - return _guideGroup; } public void LockGuideGroup(bool advance = true) { if (advance) { - NextGuideGroup(); + AdvanceGuideGroup(); } _guideGroupLocked = true;