Browse Source

fix history for playlists in yaml playouts (#2097)

pull/2098/head
Jason Dove 2 months ago committed by GitHub
parent
commit
3e07bc6136
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 14
      ErsatzTV.Core/Scheduling/YamlScheduling/EnumeratorCache.cs
  3. 25
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutApplyHistoryHandler.cs
  4. 2
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutContentHandler.cs
  5. 6
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutContentPlaylistItem.cs

2
CHANGELOG.md

@ -65,7 +65,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -65,7 +65,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- All NVIDIA docker users
- Windows NVIDIA users who have set the `ETV_DISABLE_VULKAN` env var
- Fix audio sync issue with QSV acceleration
- YAML playout: fix history for marathon content
- YAML playout: fix history for marathon and playlist content
- This allows playouts to be extended correctly, instead of always resetting to the earliest item in each group
## [25.2.0] - 2025-06-24

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

@ -112,7 +112,7 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor @@ -112,7 +112,7 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor
// playlist is a special case that needs to be handled on its own
if (content is YamlPlayoutContentPlaylistItem playlist)
{
if (!string.IsNullOrWhiteSpace(playlist.Order))
if (!string.IsNullOrWhiteSpace(playlist.Order) && !string.Equals(playlist.Order, "none", StringComparison.OrdinalIgnoreCase))
{
logger.LogWarning(
"Ignoring playback order {Order} for playlist {Playlist}",
@ -123,12 +123,12 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor @@ -123,12 +123,12 @@ public class EnumeratorCache(IMediaCollectionRepository mediaCollectionRepositor
Dictionary<PlaylistItem, List<MediaItem>> itemMap =
await mediaCollectionRepository.GetPlaylistItemMap(playlist.PlaylistGroup, playlist.Playlist);
// foreach ((PlaylistItem playlistItem, List<MediaItem> mediaItems) in itemMap)
// {
// _playlistMediaItems.Add(
// new PlaylistKey(contentKey, CollectionKey.ForPlaylistItem(playlistItem)),
// mediaItems);
// }
foreach ((PlaylistItem playlistItem, List<MediaItem> mediaItems) in itemMap)
{
_playlistMediaItems.Add(
new PlaylistKey(contentKey, CollectionKey.ForPlaylistItem(playlistItem)),
mediaItems);
}
return await PlaylistEnumerator.Create(
mediaCollectionRepository,

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

@ -53,7 +53,7 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache) @@ -53,7 +53,7 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache)
foreach (IMediaCollectionEnumerator enumerator in maybeEnumerator)
{
if (contentItem is YamlPlayoutContentMarathonItem marathonItem && enumerator is PlaylistEnumerator playlistEnumerator)
if (enumerator is PlaylistEnumerator playlistEnumerator)
{
Option<PlayoutHistory> maybePrimaryHistory = maybeHistory
.Filter(h => string.IsNullOrWhiteSpace(h.ChildKey))
@ -61,16 +61,19 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache) @@ -61,16 +61,19 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache)
foreach (PlayoutHistory primaryHistory in maybePrimaryHistory)
{
bool hasSetEnumeratorIndex = false;
if (!Enum.TryParse(marathonItem.ItemOrder, true, out PlaybackOrder itemPlaybackOrder))
{
itemPlaybackOrder = PlaybackOrder.None;
}
var hasSetEnumeratorIndex = false;
var childEnumeratorKeys = playlistEnumerator.ChildEnumerators.Map(x => x.CollectionKey).ToList();
foreach ((IMediaCollectionEnumerator childEnumerator, CollectionKey collectionKey) in playlistEnumerator.ChildEnumerators)
{
PlaybackOrder itemPlaybackOrder = childEnumerator switch
{
ChronologicalMediaCollectionEnumerator => PlaybackOrder.Chronological,
RandomizedMediaCollectionEnumerator => PlaybackOrder.Random,
ShuffledMediaCollectionEnumerator => PlaybackOrder.Shuffle,
_ => PlaybackOrder.None
};
Option<PlayoutHistory> maybeApplicableHistory = maybeHistory
.Filter(h => h.ChildKey == HistoryDetails.KeyForCollectionKey(collectionKey))
.HeadOrNone();
@ -99,8 +102,8 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache) @@ -99,8 +102,8 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache)
collectionItems,
h.Details,
childEnumerator,
playbackOrder,
!h.IsCurrentChild);
itemPlaybackOrder,
true);
}
if (h.IsCurrentChild)
@ -117,6 +120,10 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache) @@ -117,6 +120,10 @@ public class YamlPlayoutApplyHistoryHandler(EnumeratorCache enumeratorCache)
// falling back to enumerator based on index
playlistEnumerator.SetEnumeratorIndex(primaryHistory.Index);
}
// only move next at the end, because that may also move
// the enumerator index
playlistEnumerator.MoveNext();
}
}
else

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

@ -75,7 +75,7 @@ public abstract class YamlPlayoutContentHandler(EnumeratorCache enumeratorCache) @@ -75,7 +75,7 @@ public abstract class YamlPlayoutContentHandler(EnumeratorCache enumeratorCache)
string historyKey = HistoryDetails.KeyForYamlContent(contentItem);
if (contentItem is YamlPlayoutContentMarathonItem && enumerator is PlaylistEnumerator playlistEnumerator)
if (enumerator is PlaylistEnumerator playlistEnumerator)
{
// create a playout history record
var nextHistory = new PlayoutHistory

6
ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutContentPlaylistItem.cs

@ -8,4 +8,10 @@ public class YamlPlayoutContentPlaylistItem : YamlPlayoutContentItem @@ -8,4 +8,10 @@ public class YamlPlayoutContentPlaylistItem : YamlPlayoutContentItem
[YamlMember(Alias = "playlist_group", ApplyNamingConventions = false)]
public string PlaylistGroup { get; set; }
public override string Order
{
get => "none";
set => throw new NotSupportedException();
}
}

Loading…
Cancel
Save