fix guide group generation for duration yaml instruction (#1943)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<PlayoutHistory> maybeHistory = GetHistoryForItem(
|
||||
|
||||
@@ -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<PlayoutHistory> maybeHistory = GetHistoryForItem(
|
||||
|
||||
@@ -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<PlayoutHistory> 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<PlayoutHistory> maybeHistory = GetHistoryForItem(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user