Merge pull request #7176 from dmitrylyzo/fix-trailers-1
This commit is contained in:
commit
3aeae150f8
|
@ -1102,12 +1102,13 @@ namespace Emby.Server.Implementations.Dto
|
|||
|
||||
if (options.ContainsField(ItemFields.LocalTrailerCount))
|
||||
{
|
||||
allExtras ??= item.GetExtras().ToArray();
|
||||
dto.LocalTrailerCount = allExtras.Count(i => i.ExtraType == ExtraType.Trailer);
|
||||
|
||||
if (item is IHasTrailers hasTrailers)
|
||||
{
|
||||
dto.LocalTrailerCount += hasTrailers.GetTrailerCount();
|
||||
dto.LocalTrailerCount = hasTrailers.GetTrailerCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
dto.LocalTrailerCount = (allExtras ?? item.GetExtras()).Count(i => i.ExtraType == ExtraType.Trailer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,21 +206,16 @@ namespace Jellyfin.Api.Controllers
|
|||
: _libraryManager.GetItemById(itemId);
|
||||
|
||||
var dtoOptions = new DtoOptions().AddClientFields(Request);
|
||||
var dtosExtras = item.GetExtras(new[] { ExtraType.Trailer })
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
|
||||
.ToArray();
|
||||
|
||||
if (item is IHasTrailers hasTrailers)
|
||||
{
|
||||
var trailers = hasTrailers.LocalTrailers;
|
||||
var dtosTrailers = _dtoService.GetBaseItemDtos(trailers, dtoOptions, user, item);
|
||||
var allTrailers = new BaseItemDto[dtosExtras.Length + dtosTrailers.Count];
|
||||
dtosExtras.CopyTo(allTrailers, 0);
|
||||
dtosTrailers.CopyTo(allTrailers, dtosExtras.Length);
|
||||
return allTrailers;
|
||||
return Ok(_dtoService.GetBaseItemDtos(trailers, dtoOptions, user, item));
|
||||
}
|
||||
|
||||
return dtosExtras;
|
||||
return Ok(item.GetExtras()
|
||||
.Where(e => e.ExtraType == ExtraType.Trailer)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -312,7 +312,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
var trailers = new List<MediaUrl>();
|
||||
for (var i = 0; i < movieResult.Videos.Results.Count; i++)
|
||||
{
|
||||
var video = movieResult.Videos.Results[0];
|
||||
var video = movieResult.Videos.Results[i];
|
||||
if (!TmdbUtils.IsTrailerType(video))
|
||||
{
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue
Block a user