Browse Source

show chapter markers in media info (#1568)

pull/1569/head
Jason Dove 1 year ago committed by GitHub
parent
commit
33f67b88f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      CHANGELOG.md
  2. 3
      ErsatzTV.Application/MediaItems/MediaItemInfo.cs
  3. 3
      ErsatzTV.Application/MediaItems/MediaItemInfoChapter.cs
  4. 12
      ErsatzTV.Application/MediaItems/Queries/GetMediaItemInfoHandler.cs

3
CHANGELOG.md

@ -27,7 +27,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -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

3
ErsatzTV.Application/MediaItems/MediaItemInfo.cs

@ -16,4 +16,5 @@ public record MediaItemInfo( @@ -16,4 +16,5 @@ public record MediaItemInfo(
VideoScanKind VideoScanKind,
int Width,
int Height,
List<MediaItemInfoStream> Streams);
List<MediaItemInfoStream> Streams,
List<MediaItemInfoChapter> Chapters);

3
ErsatzTV.Application/MediaItems/MediaItemInfoChapter.cs

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
namespace ErsatzTV.Application.MediaItems;
public record MediaItemInfoChapter(string Title, TimeSpan StartTime, TimeSpan EndTime);

12
ErsatzTV.Application/MediaItems/Queries/GetMediaItemInfoHandler.cs

@ -31,8 +31,12 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either< @@ -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< @@ -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< @@ -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< @@ -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);
}

Loading…
Cancel
Save