fix local subtitles display (#1388)
* show external subtitles in media info * fix mysql saved page size
This commit is contained in:
@@ -3,7 +3,7 @@ using ErsatzTV.Core.Domain;
|
||||
namespace ErsatzTV.Application.MediaItems;
|
||||
|
||||
public record MediaItemInfoStream(
|
||||
int Index,
|
||||
int? Index,
|
||||
MediaStreamKind Kind,
|
||||
string Title,
|
||||
string Codec,
|
||||
|
||||
@@ -28,10 +28,14 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
|
||||
.ThenInclude(lp => lp.Library)
|
||||
.ThenInclude(l => l.MediaSource)
|
||||
// TODO: support all media types here
|
||||
.Include(i => (i as Movie).MovieMetadata)
|
||||
.ThenInclude(mv => mv.Subtitles)
|
||||
.Include(i => (i as Movie).MediaVersions)
|
||||
.ThenInclude(mv => mv.Streams)
|
||||
.Include(i => (i as Episode).MediaVersions)
|
||||
.ThenInclude(mv => mv.Streams)
|
||||
.Include(i => (i as Episode).EpisodeMetadata)
|
||||
.ThenInclude(mv => mv.Subtitles)
|
||||
.SelectOneAsync(i => i.Id, i => i.Id == request.Id)
|
||||
.MapT(Project);
|
||||
|
||||
@@ -55,6 +59,18 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
|
||||
_ => null
|
||||
};
|
||||
|
||||
List<Subtitle> subtitles = mediaItem switch
|
||||
{
|
||||
Movie m => m.MovieMetadata.Map(mm => mm.Subtitles).Flatten().ToList(),
|
||||
Episode e => e.EpisodeMetadata.Map(mm => mm.Subtitles).Flatten().ToList(),
|
||||
_ => new List<Subtitle>()
|
||||
};
|
||||
|
||||
var allStreams = version.Streams.OrderBy(s => s.Index).Map(Project).ToList();
|
||||
|
||||
// include external subtitles from local libraries
|
||||
allStreams.AddRange(subtitles.Filter(s => s.SubtitleKind is SubtitleKind.Sidecar).Map(ProjectToStream));
|
||||
|
||||
return new MediaItemInfo(
|
||||
mediaItem.Id,
|
||||
mediaItem.GetType().Name,
|
||||
@@ -69,7 +85,7 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
|
||||
version.VideoScanKind,
|
||||
version.Width,
|
||||
version.Height,
|
||||
version.Streams.OrderBy(s => s.Index).Map(Project).ToList());
|
||||
allStreams);
|
||||
}
|
||||
|
||||
private static MediaItemInfoStream Project(MediaStream mediaStream) =>
|
||||
@@ -92,4 +108,25 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either<
|
||||
mediaStream.BitsPerRawSample > 0 ? mediaStream.BitsPerRawSample : null,
|
||||
mediaStream.FileName,
|
||||
mediaStream.MimeType);
|
||||
|
||||
private static MediaItemInfoStream ProjectToStream(Subtitle subtitle) =>
|
||||
new(
|
||||
null,
|
||||
MediaStreamKind.ExternalSubtitle,
|
||||
subtitle.Title,
|
||||
subtitle.Codec,
|
||||
null,
|
||||
subtitle.Language,
|
||||
null,
|
||||
subtitle.Default ? true : null,
|
||||
subtitle.Forced ? true : null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
string.IsNullOrWhiteSpace(subtitle.Path) ? null : Path.GetFileName(subtitle.Path),
|
||||
null);
|
||||
}
|
||||
|
||||
+4426
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ErsatzTV.Infrastructure.MySql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FixPageSize : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("UPDATE ConfigElement SET Value = '10' WHERE `Key` LIKE '%page_size%' AND Value = '0'");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -7,6 +7,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<Configurations>Debug;Release;Debug No Sync</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<UserSecretsId>729e6271-c307-43c8-8e36-1b36c39f6de2</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
private MudTable<ChannelViewModel> _table;
|
||||
private List<FFmpegProfileViewModel> _ffmpegProfiles;
|
||||
|
||||
private int _rowsPerPage;
|
||||
private int _rowsPerPage = 10;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -138,9 +138,9 @@
|
||||
private MudTable<MultiCollectionViewModel> _multiCollectionsTable;
|
||||
private MudTable<SmartCollectionViewModel> _smartCollectionsTable;
|
||||
|
||||
private int _collectionsRowsPerPage;
|
||||
private int _multiCollectionsRowsPerPage;
|
||||
private int _smartCollectionsRowsPerPage;
|
||||
private int _collectionsRowsPerPage = 10;
|
||||
private int _multiCollectionsRowsPerPage = 10;
|
||||
private int _smartCollectionsRowsPerPage = 10;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
private MudTable<FillerPresetViewModel> _fillerPresetsTable;
|
||||
|
||||
private int _fillerPresetsRowsPerPage;
|
||||
private int _fillerPresetsRowsPerPage = 10;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
|
||||
private MudTable<LogEntryViewModel> _table;
|
||||
private int _rowsPerPage;
|
||||
private int _rowsPerPage = 10;
|
||||
private string _searchString;
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -121,8 +121,8 @@
|
||||
|
||||
private MudTable<PlayoutNameViewModel> _table;
|
||||
private MudTable<PlayoutItemViewModel> _detailTable;
|
||||
private int _rowsPerPage;
|
||||
private int _detailRowsPerPage;
|
||||
private int _rowsPerPage = 10;
|
||||
private int _detailRowsPerPage = 10;
|
||||
private int? _selectedPlayoutId;
|
||||
private bool _showFiller;
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
|
||||
private MudTable<ProgramScheduleViewModel> _table;
|
||||
private MudTable<ProgramScheduleItemViewModel> _detailTable;
|
||||
private int _rowsPerPage;
|
||||
private int _detailRowsPerPage;
|
||||
private int _rowsPerPage = 10;
|
||||
private int _detailRowsPerPage = 10;
|
||||
private ProgramScheduleViewModel _selectedSchedule;
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
private MudTable<TraktListViewModel> _traktListsTable;
|
||||
|
||||
private int _traktListsRowsPerPage;
|
||||
private int _traktListsRowsPerPage = 10;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user