show chapter markers in media info (#1568)

This commit is contained in:
Jason Dove
2024-01-22 14:19:35 -06:00
committed by GitHub
parent b88deaafe5
commit 33f67b88f0
4 changed files with 18 additions and 3 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `Blocks` - ordered list of items to play within the specified duration
- `Templates` - a generic "day" that consists of blocks scheduled at specific times
- `Playout Templates` - templates to schedule using the specified criteria. Only one template will be selected each day
- Much more to come on this feature as development continues
- Much more to come on this feature as development continues
- Show chapter markers in movie and episode media info
### Fixed
- Fix error loading path replacements when using MySql
@@ -16,4 +16,5 @@ public record MediaItemInfo(
VideoScanKind VideoScanKind,
int Width,
int Height,
List<MediaItemInfoStream> Streams);
List<MediaItemInfoStream> Streams,
List<MediaItemInfoChapter> Chapters);
@@ -0,0 +1,3 @@
namespace ErsatzTV.Application.MediaItems;
public record MediaItemInfoChapter(string Title, TimeSpan StartTime, TimeSpan EndTime);
@@ -31,8 +31,12 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
.Include(i => (i as Movie).MovieMetadata)
.ThenInclude(mv => mv.Subtitles)
.Include(i => (i as Movie).MediaVersions)
.ThenInclude(mv => mv.Chapters)
.Include(i => (i as Movie).MediaVersions)
.ThenInclude(mv => mv.Streams)
.Include(i => (i as Episode).MediaVersions)
.ThenInclude(mv => mv.Chapters)
.Include(i => (i as Episode).MediaVersions)
.ThenInclude(mv => mv.Streams)
.Include(i => (i as Episode).EpisodeMetadata)
.ThenInclude(mv => mv.Subtitles)
@@ -71,6 +75,8 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
// include external subtitles from local libraries
allStreams.AddRange(subtitles.Filter(s => s.SubtitleKind is SubtitleKind.Sidecar).Map(ProjectToStream));
var allChapters = (version.Chapters ?? []).OrderBy(c => c.StartTime).Map(Project).ToList();
return new MediaItemInfo(
mediaItem.Id,
mediaItem.GetType().Name,
@@ -85,7 +91,8 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
version.VideoScanKind,
version.Width,
version.Height,
allStreams);
allStreams,
allChapters);
}
private static MediaItemInfoStream Project(MediaStream mediaStream) =>
@@ -129,4 +136,7 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
null,
string.IsNullOrWhiteSpace(subtitle.Path) ? null : Path.GetFileName(subtitle.Path),
null);
private static MediaItemInfoChapter Project(MediaChapter chapter) =>
new(chapter.Title, chapter.StartTime, chapter.EndTime);
}