only discard items with random or shuffle playback order (#1309)
This commit is contained in:
@@ -108,7 +108,21 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
|
||||
}
|
||||
|
||||
private static Task<Validation<BaseError, Playout>> Validate(TvContext dbContext, BuildPlayout request) =>
|
||||
PlayoutMustExist(dbContext, request);
|
||||
PlayoutMustExist(dbContext, request).BindT(DiscardAttemptsMustBeValid);
|
||||
|
||||
private static Validation<BaseError, Playout> DiscardAttemptsMustBeValid(Playout playout)
|
||||
{
|
||||
foreach (ProgramScheduleItemDuration item in playout.ProgramSchedule.Items.OfType<ProgramScheduleItemDuration>())
|
||||
{
|
||||
item.DiscardToFillAttempts = item.PlaybackOrder switch
|
||||
{
|
||||
PlaybackOrder.Random or PlaybackOrder.Shuffle => item.DiscardToFillAttempts,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
return playout;
|
||||
}
|
||||
|
||||
private static Task<Validation<BaseError, Playout>> PlayoutMustExist(
|
||||
TvContext dbContext,
|
||||
|
||||
@@ -253,7 +253,7 @@ public abstract class ProgramScheduleItemCommandBase
|
||||
PlaybackOrder = item.PlaybackOrder,
|
||||
PlayoutDuration = FixDuration(item.PlayoutDuration.GetValueOrDefault()),
|
||||
TailMode = item.TailMode,
|
||||
DiscardToFillAttempts = item.DiscardToFillAttempts.GetValueOrDefault(),
|
||||
DiscardToFillAttempts = FixDiscardToFillAttempts(item.PlaybackOrder, item.DiscardToFillAttempts.GetValueOrDefault()),
|
||||
CustomTitle = item.CustomTitle,
|
||||
GuideMode = item.GuideMode,
|
||||
PreRollFillerId = item.PreRollFillerId,
|
||||
@@ -277,4 +277,10 @@ public abstract class ProgramScheduleItemCommandBase
|
||||
startTime.HasValue && startTime.Value >= TimeSpan.FromDays(1)
|
||||
? startTime.Value.Subtract(TimeSpan.FromDays(1))
|
||||
: startTime;
|
||||
|
||||
private static int FixDiscardToFillAttempts(PlaybackOrder playbackOrder, int value) => playbackOrder switch
|
||||
{
|
||||
PlaybackOrder.Random or PlaybackOrder.Shuffle => value,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
|
||||
if (nextState.CurrentTime + itemDuration > nextItemStart)
|
||||
{
|
||||
_logger.LogDebug(
|
||||
"Filler with duration {Duration} will go past next item start {NextItemStart}",
|
||||
"Filler with duration {Duration:hh\\:mm\\:ss} will go past next item start {NextItemStart}",
|
||||
itemDuration,
|
||||
nextItemStart);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PlayoutModeSchedulerDuration : PlayoutModeSchedulerBase<ProgramSche
|
||||
if (itemDuration > scheduleItem.PlayoutDuration)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"Skipping playout item {Title} with duration {Duration} that is longer than schedule item duration {PlayoutDuration}",
|
||||
"Skipping playout item {Title} with duration {Duration:hh\\:mm\\:ss} that will never fit in schedule item duration {PlayoutDuration:hh\\:mm\\:ss}",
|
||||
PlayoutBuilder.DisplayTitle(mediaItem),
|
||||
itemDuration,
|
||||
scheduleItem.PlayoutDuration);
|
||||
@@ -87,7 +87,7 @@ public class PlayoutModeSchedulerDuration : PlayoutModeSchedulerBase<ProgramSche
|
||||
else
|
||||
{
|
||||
_logger.LogDebug(
|
||||
"Skipping playout item {Title} with duration {Duration} that is longer than remaining duration {RemainingDuration}",
|
||||
"Skipping playout item {Title} with duration {Duration:hh\\:mm\\:ss} that is longer than remaining duration {RemainingDuration:hh\\:mm\\:ss}",
|
||||
PlayoutBuilder.DisplayTitle(mediaItem),
|
||||
itemDuration,
|
||||
remainingDuration);
|
||||
@@ -175,7 +175,7 @@ public class PlayoutModeSchedulerDuration : PlayoutModeSchedulerBase<ProgramSche
|
||||
if (itemEndTimeWithFiller - itemStartTime > scheduleItem.PlayoutDuration)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"Unable to schedule duration block of {DurationBlock} which is longer than the configured playout duration {PlayoutDuration}",
|
||||
"Unable to schedule duration block of {DurationBlock:hh\\:mm\\:ss} which is longer than the configured playout duration {PlayoutDuration:hh\\:mm\\:ss}",
|
||||
durationBlock,
|
||||
scheduleItem.PlayoutDuration);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider
|
||||
{
|
||||
string time = match.Groups[1].Value;
|
||||
var duration = TimeSpan.Parse(time, NumberFormatInfo.InvariantInfo);
|
||||
_logger.LogInformation("Analyzed duration is {Duration}", duration);
|
||||
_logger.LogInformation("Analyzed duration is {Duration:hh\\:mm\\:ss}", duration);
|
||||
version.Duration = duration;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user