Browse Source

improve shuffling behavior; add custom_title (#1838)

* improve yaml shuffling behavior

* add custom_title to playout instructions
pull/1839/head
Jason Dove 1 year ago committed by GitHub
parent
commit
961fe8bbf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      ErsatzTV.Core/Scheduling/BlockScheduling/BlockPlayoutShuffledMediaCollectionEnumerator.cs
  2. 5
      ErsatzTV.Core/Scheduling/YamlScheduling/EnumeratorCache.cs
  3. 2
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs
  4. 16
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutApplyHistoryHandler.cs
  5. 2
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs
  6. 5
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs
  7. 1
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPadToNextHandler.cs
  8. 1
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPadUntilHandler.cs
  9. 3
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutInstruction.cs

9
ErsatzTV.Core/Scheduling/BlockScheduling/BlockPlayoutShuffledMediaCollectionEnumerator.cs

@ -45,7 +45,14 @@ public class BlockPlayoutShuffledMediaCollectionEnumerator : IMediaCollectionEnu @@ -45,7 +45,14 @@ public class BlockPlayoutShuffledMediaCollectionEnumerator : IMediaCollectionEnu
public Option<MediaItem> Current => _shuffled.Any() ? _shuffled[State.Index % _mediaItemCount] : None;
public Option<bool> CurrentIncludeInProgramGuide { get; }
public void MoveNext() => State.Index++;
public void MoveNext()
{
State.Index++;
if (State.Index % _mediaItemCount == 0)
{
_shuffled = Shuffle(_mediaItems);
}
}
public Option<TimeSpan> MinimumDuration => _lazyMinimumDuration.Value;

5
ErsatzTV.Core/Scheduling/YamlScheduling/EnumeratorCache.cs

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.Core.Interfaces.Scheduling;
using ErsatzTV.Core.Scheduling.BlockScheduling;
using ErsatzTV.Core.Scheduling.YamlScheduling.Models;
namespace ErsatzTV.Core.Scheduling.YamlScheduling;
@ -48,7 +49,7 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor @@ -48,7 +49,7 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor
private async Task<Option<IMediaCollectionEnumerator>> GetEnumeratorForContent(
YamlPlayoutContext context,
string contentKey,
CancellationToken cancellationToken)
CancellationToken _)
{
int index = context.Definition.Content.FindIndex(c => c.Key == contentKey);
if (index < 0)
@ -82,7 +83,7 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor @@ -82,7 +83,7 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor
List<GroupedMediaItem> groupedMediaItems = keepMultiPartEpisodesTogether
? MultiPartEpisodeGrouper.GroupMediaItems(items, treatCollectionsAsShows: false)
: items.Map(mi => new GroupedMediaItem(mi, null)).ToList();
return new ShuffledMediaCollectionEnumerator(groupedMediaItems, state, cancellationToken);
return new BlockPlayoutShuffledMediaCollectionEnumerator(groupedMediaItems, state);
}
return Option<IMediaCollectionEnumerator>.None;

2
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs

@ -42,7 +42,7 @@ public class YamlPlayoutAllHandler(EnumeratorCache enumeratorCache) : YamlPlayou @@ -42,7 +42,7 @@ public class YamlPlayoutAllHandler(EnumeratorCache enumeratorCache) : YamlPlayou
InPoint = TimeSpan.Zero,
OutPoint = itemDuration,
FillerKind = GetFillerKind(all),
//CustomTitle = scheduleItem.CustomTitle,
CustomTitle = string.IsNullOrWhiteSpace(all.CustomTitle) ? null : all.CustomTitle,
//WatermarkId = scheduleItem.WatermarkId,
//PreferredAudioLanguageCode = scheduleItem.PreferredAudioLanguageCode,
//PreferredAudioTitle = scheduleItem.PreferredAudioTitle,

16
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutApplyHistoryHandler.cs

@ -53,11 +53,17 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache) @@ -53,11 +53,17 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache)
{
logger.LogDebug("History is applicable: {When}: {History}", h.When, h.Details);
HistoryDetails.MoveToNextItem(
collectionItems,
h.Details,
enumerator,
playbackOrder);
enumerator.ResetState(
new CollectionEnumeratorState { Seed = enumerator.State.Seed, Index = h.Index + 1 });
if (playbackOrder is PlaybackOrder.Chronological)
{
HistoryDetails.MoveToNextItem(
collectionItems,
h.Details,
enumerator,
playbackOrder);
}
}
}

2
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs

@ -42,7 +42,7 @@ public class YamlPlayoutCountHandler(EnumeratorCache enumeratorCache) : YamlPlay @@ -42,7 +42,7 @@ public class YamlPlayoutCountHandler(EnumeratorCache enumeratorCache) : YamlPlay
InPoint = TimeSpan.Zero,
OutPoint = itemDuration,
FillerKind = GetFillerKind(count),
//CustomTitle = scheduleItem.CustomTitle,
CustomTitle = string.IsNullOrWhiteSpace(count.CustomTitle) ? null : count.CustomTitle,
//WatermarkId = scheduleItem.WatermarkId,
//PreferredAudioLanguageCode = scheduleItem.PreferredAudioLanguageCode,
//PreferredAudioTitle = scheduleItem.PreferredAudioTitle,

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

@ -52,6 +52,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP @@ -52,6 +52,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
duration.Trim,
duration.OfflineTail,
GetFillerKind(duration),
duration.CustomTitle,
enumerator,
fallbackEnumerator);
@ -70,6 +71,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP @@ -70,6 +71,7 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
bool trim,
bool offlineTail,
FillerKind fillerKind,
string customTitle,
IMediaCollectionEnumerator enumerator,
Option<IMediaCollectionEnumerator> fallbackEnumerator)
{
@ -89,7 +91,8 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP @@ -89,7 +91,8 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
InPoint = TimeSpan.Zero,
OutPoint = itemDuration,
GuideGroup = context.NextGuideGroup(),
FillerKind = fillerKind
FillerKind = fillerKind,
CustomTitle = string.IsNullOrWhiteSpace(customTitle) ? null : customTitle
//DisableWatermarks = !allowWatermarks
};

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

@ -60,6 +60,7 @@ public class YamlPlayoutPadToNextHandler(EnumeratorCache enumeratorCache) : Yaml @@ -60,6 +60,7 @@ public class YamlPlayoutPadToNextHandler(EnumeratorCache enumeratorCache) : Yaml
padToNext.Trim,
offlineTail: true,
GetFillerKind(padToNext),
padToNext.CustomTitle,
enumerator,
fallbackEnumerator);

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

@ -70,6 +70,7 @@ public class YamlPlayoutPadUntilHandler(EnumeratorCache enumeratorCache) : YamlP @@ -70,6 +70,7 @@ public class YamlPlayoutPadUntilHandler(EnumeratorCache enumeratorCache) : YamlP
padUntil.Trim,
offlineTail: true,
GetFillerKind(padUntil),
padUntil.CustomTitle,
enumerator,
fallbackEnumerator);

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

@ -11,6 +11,9 @@ public class YamlPlayoutInstruction @@ -11,6 +11,9 @@ public class YamlPlayoutInstruction
[YamlMember(Alias = "filler_kind", ApplyNamingConventions = false)]
public string FillerKind { get; set; }
[YamlMember(Alias = "custom_title", ApplyNamingConventions = false)]
public string CustomTitle { get; set; }
[YamlIgnore]
public string SequenceKey { get; set; }

Loading…
Cancel
Save