Browse Source

fix local subtitles display (#1388)

* show external subtitles in media info

* fix mysql saved page size
pull/1389/head
Jason Dove 2 years ago committed by GitHub
parent
commit
560cb826b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ErsatzTV.Application/MediaItems/MediaItemInfoStream.cs
  2. 39
      ErsatzTV.Application/MediaItems/Queries/GetMediaItemInfoHandler.cs
  3. 4426
      ErsatzTV.Infrastructure.MySql/Migrations/20230819162134_FixPageSize.Designer.cs
  4. 21
      ErsatzTV.Infrastructure.MySql/Migrations/20230819162134_FixPageSize.cs
  5. 3
      ErsatzTV.Scanner/ErsatzTV.Scanner.csproj
  6. 2
      ErsatzTV/Pages/Channels.razor
  7. 6
      ErsatzTV/Pages/Collections.razor
  8. 2
      ErsatzTV/Pages/FillerPresets.razor
  9. 2
      ErsatzTV/Pages/Logs.razor
  10. 4
      ErsatzTV/Pages/Playouts.razor
  11. 4
      ErsatzTV/Pages/Schedules.razor
  12. 2
      ErsatzTV/Pages/TraktLists.razor
  13. 3
      ErsatzTV/Properties/launchSettings.json

2
ErsatzTV.Application/MediaItems/MediaItemInfoStream.cs

@ -3,7 +3,7 @@ using ErsatzTV.Core.Domain; @@ -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,

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

@ -28,10 +28,14 @@ public class GetMediaItemInfoHandler : IRequestHandler<GetMediaItemInfo, Either< @@ -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< @@ -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< @@ -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< @@ -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
ErsatzTV.Infrastructure.MySql/Migrations/20230819162134_FixPageSize.Designer.cs generated

File diff suppressed because it is too large Load Diff

21
ErsatzTV.Infrastructure.MySql/Migrations/20230819162134_FixPageSize.cs

@ -0,0 +1,21 @@ @@ -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)
{
}
}
}

3
ErsatzTV.Scanner/ErsatzTV.Scanner.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
@ -7,6 +7,7 @@ @@ -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>

2
ErsatzTV/Pages/Channels.razor

@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
private MudTable<ChannelViewModel> _table;
private List<FFmpegProfileViewModel> _ffmpegProfiles;
private int _rowsPerPage;
private int _rowsPerPage = 10;
public void Dispose()
{

6
ErsatzTV/Pages/Collections.razor

@ -138,9 +138,9 @@ @@ -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()
{

2
ErsatzTV/Pages/FillerPresets.razor

@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
private MudTable<FillerPresetViewModel> _fillerPresetsTable;
private int _fillerPresetsRowsPerPage;
private int _fillerPresetsRowsPerPage = 10;
public void Dispose()
{

2
ErsatzTV/Pages/Logs.razor

@ -51,7 +51,7 @@ @@ -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()

4
ErsatzTV/Pages/Playouts.razor

@ -121,8 +121,8 @@ @@ -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;

4
ErsatzTV/Pages/Schedules.razor

@ -98,8 +98,8 @@ @@ -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()

2
ErsatzTV/Pages/TraktLists.razor

@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
private MudTable<TraktListViewModel> _traktListsTable;
private int _traktListsRowsPerPage;
private int _traktListsRowsPerPage = 10;
public void Dispose()
{

3
ErsatzTV/Properties/launchSettings.json

@ -4,7 +4,8 @@ @@ -4,7 +4,8 @@
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development"
}
}
}

Loading…
Cancel
Save