From fdc24ec2eeffec4334c705631439de72cf6c8bdd Mon Sep 17 00:00:00 2001 From: SL1288 Date: Mon, 19 Aug 2019 18:40:39 +0200 Subject: [PATCH] Fix LocalTrailers playback. --- Emby.Server.Implementations/Dto/DtoService.cs | 2 +- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 10 ++++++---- MediaBrowser.Controller/Entities/BaseItem.cs | 8 ++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 1a7f10634b..97ddfff530 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1079,7 +1079,7 @@ namespace Emby.Server.Implementations.Dto allExtras = item.GetExtras().ToArray(); } - dto.LocalTrailerCount = allExtras.Count(i => i.ExtraType.HasValue && i.ExtraType.Value == ExtraType.Trailer); + dto.LocalTrailerCount = allExtras.Count(i => i.ExtraType.HasValue && i.ExtraType.Value == ExtraType.Trailer) + item.GetTrailers().Count(); } // Add EpisodeInfo diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index a9b06095da..6eaa1b692f 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -366,11 +366,13 @@ namespace MediaBrowser.Api.UserLibrary var dtoOptions = GetDtoOptions(_authContext, request); - var dtos = item.GetExtras(new[] { ExtraType.Trailer }) - .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)) - .ToArray(); + var dtosExtras = item.GetExtras(new[] { ExtraType.Trailer }) + .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)); + + var dtosTrailers = item.GetTrailers() + .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)); - return ToOptimizedResult(dtos); + return ToOptimizedResult(dtosExtras.Concat(dtosTrailers).ToArray()); } /// diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 2ae856b020..38e4db3cf7 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -2883,6 +2883,14 @@ namespace MediaBrowser.Controller.Entities return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null && extraTypes.Contains(i.ExtraType.Value)).OrderBy(i => i.SortName); } + public IEnumerable GetTrailers() + { + if (this is IHasTrailers) + return ((IHasTrailers)this).LocalTrailerIds.Select(LibraryManager.GetItemById).Where(i => i != null).OrderBy(i => i.SortName); + else + return Array.Empty(); + } + public IEnumerable GetDisplayExtras() { return GetExtras(DisplayExtraTypes);