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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
DebugBreak.Break();
|
||||||
|
|
||||||
_client.Notify(ex);
|
_client.Notify(ex);
|
||||||
return BaseError.New(
|
return BaseError.New(
|
||||||
$"Unexpected error building playout for channel {playout.Channel.Name}: {ex.Message}");
|
$"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<bool> IsCustomPlaybackOrder(int collectionId) => false.AsTask();
|
||||||
public Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection) => Option<string>.None.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();
|
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> UpdateOutline(EpisodeMetadata metadata, string outline) => throw new NotSupportedException();
|
||||||
|
|
||||||
public Task<bool> UpdatePlot(EpisodeMetadata metadata, string plot) => 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<List<int>> PlayoutIdsUsingSmartCollection(int smartCollectionId);
|
||||||
Task<bool> IsCustomPlaybackOrder(int collectionId);
|
Task<bool> IsCustomPlaybackOrder(int collectionId);
|
||||||
Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection);
|
Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection);
|
||||||
List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items);
|
List<CollectionWithItems> GroupIntoFakeCollections(List<MediaItem> items, string fakeKey = null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,37 +18,43 @@ public class CollectionKey : Record<CollectionKey>
|
|||||||
ProgramScheduleItemCollectionType.Collection => new CollectionKey
|
ProgramScheduleItemCollectionType.Collection => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
CollectionId = item.CollectionId
|
CollectionId = item.CollectionId,
|
||||||
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
ProgramScheduleItemCollectionType.TelevisionShow => new CollectionKey
|
ProgramScheduleItemCollectionType.TelevisionShow => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
MediaItemId = item.MediaItemId
|
MediaItemId = item.MediaItemId,
|
||||||
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
ProgramScheduleItemCollectionType.TelevisionSeason => new CollectionKey
|
ProgramScheduleItemCollectionType.TelevisionSeason => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
MediaItemId = item.MediaItemId
|
MediaItemId = item.MediaItemId,
|
||||||
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
ProgramScheduleItemCollectionType.Artist => new CollectionKey
|
ProgramScheduleItemCollectionType.Artist => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
MediaItemId = item.MediaItemId
|
MediaItemId = item.MediaItemId,
|
||||||
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
ProgramScheduleItemCollectionType.MultiCollection => new CollectionKey
|
ProgramScheduleItemCollectionType.MultiCollection => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
MultiCollectionId = item.MultiCollectionId
|
MultiCollectionId = item.MultiCollectionId,
|
||||||
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
ProgramScheduleItemCollectionType.SmartCollection => new CollectionKey
|
ProgramScheduleItemCollectionType.SmartCollection => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
SmartCollectionId = item.SmartCollectionId
|
SmartCollectionId = item.SmartCollectionId,
|
||||||
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
ProgramScheduleItemCollectionType.FakeCollection => new CollectionKey
|
ProgramScheduleItemCollectionType.FakeCollection => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = item.CollectionType,
|
CollectionType = item.CollectionType,
|
||||||
FakeCollectionKey = item.FakeCollectionKey
|
FakeCollectionKey = item.FakeCollectionKey
|
||||||
},
|
},
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(item))
|
_ => throw new ArgumentOutOfRangeException(nameof(item))
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -447,7 +447,15 @@ public class PlayoutBuilder : IPlayoutBuilder
|
|||||||
_televisionRepository,
|
_televisionRepository,
|
||||||
_artistRepository,
|
_artistRepository,
|
||||||
collectionKey);
|
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))
|
.Filter(c => c.ShowId > 0 || c.ArtistId > 0 || !string.IsNullOrWhiteSpace(c.Key))
|
||||||
.ToList();
|
.ToList();
|
||||||
List<ProgramScheduleItem> fakeScheduleItems = [];
|
List<ProgramScheduleItem> fakeScheduleItems = [];
|
||||||
@@ -465,17 +473,19 @@ public class PlayoutBuilder : IPlayoutBuilder
|
|||||||
var (showId, _, _) when showId > 0 => new CollectionKey
|
var (showId, _, _) when showId > 0 => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = ProgramScheduleItemCollectionType.TelevisionShow,
|
CollectionType = ProgramScheduleItemCollectionType.TelevisionShow,
|
||||||
MediaItemId = showId
|
MediaItemId = showId,
|
||||||
|
FakeCollectionKey = collectionKeyString
|
||||||
},
|
},
|
||||||
var (_, artistId, _) when artistId > 0 => new CollectionKey
|
var (_, artistId, _) when artistId > 0 => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = ProgramScheduleItemCollectionType.Artist,
|
CollectionType = ProgramScheduleItemCollectionType.Artist,
|
||||||
MediaItemId = artistId
|
MediaItemId = artistId,
|
||||||
|
FakeCollectionKey = collectionKeyString
|
||||||
},
|
},
|
||||||
var (_, _, k) when k is not null => new CollectionKey
|
var (_, _, k) when k is not null => new CollectionKey
|
||||||
{
|
{
|
||||||
CollectionType = ProgramScheduleItemCollectionType.FakeCollection,
|
CollectionType = ProgramScheduleItemCollectionType.FakeCollection,
|
||||||
FakeCollectionKey = k
|
FakeCollectionKey = collectionKeyString
|
||||||
},
|
},
|
||||||
var (_, _, _) => null
|
var (_, _, _) => null
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("Performance", "CA1822:Mark members as static")]
|
[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;
|
int id = -1;
|
||||||
var result = new List<CollectionWithItems>();
|
var result = new List<CollectionWithItems>();
|
||||||
@@ -360,7 +360,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
|||||||
new CollectionWithItems(
|
new CollectionWithItems(
|
||||||
showId,
|
showId,
|
||||||
0,
|
0,
|
||||||
null,
|
fakeKey,
|
||||||
list,
|
list,
|
||||||
true,
|
true,
|
||||||
PlaybackOrder.Chronological,
|
PlaybackOrder.Chronological,
|
||||||
@@ -388,7 +388,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
|||||||
new CollectionWithItems(
|
new CollectionWithItems(
|
||||||
0,
|
0,
|
||||||
artistId,
|
artistId,
|
||||||
null,
|
fakeKey,
|
||||||
list,
|
list,
|
||||||
true,
|
true,
|
||||||
PlaybackOrder.Chronological,
|
PlaybackOrder.Chronological,
|
||||||
@@ -429,7 +429,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
|||||||
new CollectionWithItems(
|
new CollectionWithItems(
|
||||||
id,
|
id,
|
||||||
id,
|
id,
|
||||||
allArtists[index],
|
$"{fakeKey}:artist:{allArtists[index]}",
|
||||||
list,
|
list,
|
||||||
true,
|
true,
|
||||||
PlaybackOrder.Chronological,
|
PlaybackOrder.Chronological,
|
||||||
@@ -442,7 +442,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
|||||||
new CollectionWithItems(
|
new CollectionWithItems(
|
||||||
id,
|
id,
|
||||||
id,
|
id,
|
||||||
null,
|
fakeKey,
|
||||||
items.OfType<Movie>().Cast<MediaItem>().ToList(),
|
items.OfType<Movie>().Cast<MediaItem>().ToList(),
|
||||||
true,
|
true,
|
||||||
PlaybackOrder.Chronological,
|
PlaybackOrder.Chronological,
|
||||||
@@ -453,7 +453,7 @@ public class MediaCollectionRepository : IMediaCollectionRepository
|
|||||||
new CollectionWithItems(
|
new CollectionWithItems(
|
||||||
id,
|
id,
|
||||||
id,
|
id,
|
||||||
null,
|
fakeKey,
|
||||||
items.OfType<OtherVideo>().Cast<MediaItem>().ToList(),
|
items.OfType<OtherVideo>().Cast<MediaItem>().ToList(),
|
||||||
true,
|
true,
|
||||||
PlaybackOrder.Chronological,
|
PlaybackOrder.Chronological,
|
||||||
|
|||||||
Reference in New Issue
Block a user