fix fill with group when show is also included individually (#1544)
This commit is contained in:
@@ -97,6 +97,8 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugBreak.Break();
|
||||
|
||||
_client.Notify(ex);
|
||||
return BaseError.New(
|
||||
$"Unexpected error building playout for channel {playout.Channel.Name}: {ex.Message}");
|
||||
|
||||
@@ -35,6 +35,6 @@ public class FakeMediaCollectionRepository : IMediaCollectionRepository
|
||||
public Task<bool> IsCustomPlaybackOrder(int collectionId) => false.AsTask();
|
||||
public Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection) => Option<string>.None.AsTask();
|
||||
|
||||
public List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items) =>
|
||||
public List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items, string fakeKey = null) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -81,4 +81,5 @@ public class FakeTelevisionRepository : ITelevisionRepository
|
||||
public Task<bool> UpdateOutline(EpisodeMetadata metadata, string outline) => throw new NotSupportedException();
|
||||
|
||||
public Task<bool> UpdatePlot(EpisodeMetadata metadata, string plot) => throw new NotSupportedException();
|
||||
public Task<bool> UpdateYear(ShowMetadata metadata, int? year) => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ErsatzTV.Core;
|
||||
|
||||
public static class DebugBreak
|
||||
{
|
||||
[DebuggerHidden]
|
||||
[Conditional("DEBUG")]
|
||||
public static void Break()
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,5 @@ public interface IMediaCollectionRepository
|
||||
Task<List<int>> PlayoutIdsUsingSmartCollection(int smartCollectionId);
|
||||
Task<bool> IsCustomPlaybackOrder(int collectionId);
|
||||
Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection);
|
||||
List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items);
|
||||
List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items, string fakeKey = null);
|
||||
}
|
||||
|
||||
@@ -18,32 +18,38 @@ public class CollectionKey : Record<CollectionKey>
|
||||
ProgramScheduleItemCollectionType.Collection => new CollectionKey
|
||||
{
|
||||
CollectionType = item.CollectionType,
|
||||
CollectionId = item.CollectionId
|
||||
CollectionId = item.CollectionId,
|
||||
FakeCollectionKey = item.FakeCollectionKey
|
||||
},
|
||||
ProgramScheduleItemCollectionType.TelevisionShow => new CollectionKey
|
||||
{
|
||||
CollectionType = item.CollectionType,
|
||||
MediaItemId = item.MediaItemId
|
||||
MediaItemId = item.MediaItemId,
|
||||
FakeCollectionKey = item.FakeCollectionKey
|
||||
},
|
||||
ProgramScheduleItemCollectionType.TelevisionSeason => new CollectionKey
|
||||
{
|
||||
CollectionType = item.CollectionType,
|
||||
MediaItemId = item.MediaItemId
|
||||
MediaItemId = item.MediaItemId,
|
||||
FakeCollectionKey = item.FakeCollectionKey
|
||||
},
|
||||
ProgramScheduleItemCollectionType.Artist => new CollectionKey
|
||||
{
|
||||
CollectionType = item.CollectionType,
|
||||
MediaItemId = item.MediaItemId
|
||||
MediaItemId = item.MediaItemId,
|
||||
FakeCollectionKey = item.FakeCollectionKey
|
||||
},
|
||||
ProgramScheduleItemCollectionType.MultiCollection => new CollectionKey
|
||||
{
|
||||
CollectionType = item.CollectionType,
|
||||
MultiCollectionId = item.MultiCollectionId
|
||||
MultiCollectionId = item.MultiCollectionId,
|
||||
FakeCollectionKey = item.FakeCollectionKey
|
||||
},
|
||||
ProgramScheduleItemCollectionType.SmartCollection => new CollectionKey
|
||||
{
|
||||
CollectionType = item.CollectionType,
|
||||
SmartCollectionId = item.SmartCollectionId
|
||||
SmartCollectionId = item.SmartCollectionId,
|
||||
FakeCollectionKey = item.FakeCollectionKey
|
||||
},
|
||||
ProgramScheduleItemCollectionType.FakeCollection => new CollectionKey
|
||||
{
|
||||
|
||||
@@ -447,7 +447,15 @@ public class PlayoutBuilder : IPlayoutBuilder
|
||||
_televisionRepository,
|
||||
_artistRepository,
|
||||
collectionKey);
|
||||
var fakeCollections = _mediaCollectionRepository.GroupIntoFakeCollections(mediaItems)
|
||||
string collectionKeyString = JsonConvert.SerializeObject(
|
||||
collectionKey,
|
||||
Formatting.None,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
collectionKeyString = $"{scheduleItem.Id}:{collectionKeyString}";
|
||||
var fakeCollections = _mediaCollectionRepository.GroupIntoFakeCollections(mediaItems, collectionKeyString)
|
||||
.Filter(c => c.ShowId > 0 || c.ArtistId > 0 || !string.IsNullOrWhiteSpace(c.Key))
|
||||
.ToList();
|
||||
List<ProgramScheduleItem> fakeScheduleItems = [];
|
||||
@@ -465,17 +473,19 @@ public class PlayoutBuilder : IPlayoutBuilder
|
||||
var (showId, _, _) when showId > 0 => new CollectionKey
|
||||
{
|
||||
CollectionType = ProgramScheduleItemCollectionType.TelevisionShow,
|
||||
MediaItemId = showId
|
||||
MediaItemId = showId,
|
||||
FakeCollectionKey = collectionKeyString
|
||||
},
|
||||
var (_, artistId, _) when artistId > 0 => new CollectionKey
|
||||
{
|
||||
CollectionType = ProgramScheduleItemCollectionType.Artist,
|
||||
MediaItemId = artistId
|
||||
MediaItemId = artistId,
|
||||
FakeCollectionKey = collectionKeyString
|
||||
},
|
||||
var (_, _, k) when k is not null => new CollectionKey
|
||||
{
|
||||
CollectionType = ProgramScheduleItemCollectionType.FakeCollection,
|
||||
FakeCollectionKey = k
|
||||
FakeCollectionKey = collectionKeyString
|
||||
},
|
||||
var (_, _, _) => null
|
||||
};
|
||||
|
||||
@@ -334,7 +334,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
||||
}
|
||||
|
||||
[SuppressMessage("Performance", "CA1822:Mark members as static")]
|
||||
public List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items)
|
||||
public List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items, string fakeKey = null)
|
||||
{
|
||||
int id = -1;
|
||||
var result = new List<CollectionWithItems>();
|
||||
@@ -360,7 +360,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
||||
new CollectionWithItems(
|
||||
showId,
|
||||
0,
|
||||
null,
|
||||
fakeKey,
|
||||
list,
|
||||
true,
|
||||
PlaybackOrder.Chronological,
|
||||
@@ -388,7 +388,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
||||
new CollectionWithItems(
|
||||
0,
|
||||
artistId,
|
||||
null,
|
||||
fakeKey,
|
||||
list,
|
||||
true,
|
||||
PlaybackOrder.Chronological,
|
||||
@@ -429,7 +429,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
||||
new CollectionWithItems(
|
||||
id,
|
||||
id,
|
||||
allArtists[index],
|
||||
$"{fakeKey}:artist:{allArtists[index]}",
|
||||
list,
|
||||
true,
|
||||
PlaybackOrder.Chronological,
|
||||
@@ -442,7 +442,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
||||
new CollectionWithItems(
|
||||
id,
|
||||
id,
|
||||
null,
|
||||
fakeKey,
|
||||
items.OfType<Movie>().Cast<MediaItem>().ToList(),
|
||||
true,
|
||||
PlaybackOrder.Chronological,
|
||||
@@ -453,7 +453,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
||||
new CollectionWithItems(
|
||||
id,
|
||||
id,
|
||||
null,
|
||||
fakeKey,
|
||||
items.OfType<OtherVideo>().Cast<MediaItem>().ToList(),
|
||||
true,
|
||||
PlaybackOrder.Chronological,
|
||||
|
||||
Reference in New Issue
Block a user