2021-05-06 15:39:20 -07:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 12:56:24 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 13:01:16 -07:00
|
|
|
using System;
|
2018-12-27 16:27:57 -07:00
|
|
|
using System.Collections.Generic;
|
2019-01-13 12:25:32 -07:00
|
|
|
using MediaBrowser.Model.Entities;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
{
|
|
|
|
public interface IHasTrailers : IHasProviderIds
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the remote trailers.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The remote trailers.</value>
|
2019-09-01 23:19:29 -07:00
|
|
|
IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the local trailer ids.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The local trailer ids.</value>
|
2019-09-01 23:19:29 -07:00
|
|
|
IReadOnlyList<Guid> LocalTrailerIds { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the remote trailer ids.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The remote trailer ids.</value>
|
|
|
|
IReadOnlyList<Guid> RemoteTrailerIds { get; set; }
|
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
Guid Id { get; set; }
|
|
|
|
}
|
|
|
|
|
2019-09-01 23:19:29 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Class providing extension methods for working with <see cref="IHasTrailers" />.
|
|
|
|
/// </summary>
|
2018-12-27 16:27:57 -07:00
|
|
|
public static class HasTrailerExtensions
|
|
|
|
{
|
2019-09-01 23:19:29 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the trailer count.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns><see cref="IReadOnlyList{Guid}" />.</returns>
|
|
|
|
public static int GetTrailerCount(this IHasTrailers item)
|
|
|
|
=> item.LocalTrailerIds.Count + item.RemoteTrailerIds.Count;
|
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the trailer ids.
|
|
|
|
/// </summary>
|
2019-09-01 23:19:29 -07:00
|
|
|
/// <returns><see cref="IReadOnlyList{Guid}" />.</returns>
|
|
|
|
public static IReadOnlyList<Guid> GetTrailerIds(this IHasTrailers item)
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
2019-09-01 23:19:29 -07:00
|
|
|
var localIds = item.LocalTrailerIds;
|
|
|
|
var remoteIds = item.RemoteTrailerIds;
|
|
|
|
|
|
|
|
var all = new Guid[localIds.Count + remoteIds.Count];
|
|
|
|
var index = 0;
|
|
|
|
foreach (var id in localIds)
|
|
|
|
{
|
|
|
|
all[index++] = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var id in remoteIds)
|
|
|
|
{
|
|
|
|
all[index++] = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return all;
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
|
2019-09-01 23:19:29 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the trailers.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns><see cref="IReadOnlyList{BaseItem}" />.</returns>
|
|
|
|
public static IReadOnlyList<BaseItem> GetTrailers(this IHasTrailers item)
|
|
|
|
{
|
|
|
|
var localIds = item.LocalTrailerIds;
|
|
|
|
var remoteIds = item.RemoteTrailerIds;
|
|
|
|
var libraryManager = BaseItem.LibraryManager;
|
|
|
|
|
|
|
|
var all = new BaseItem[localIds.Count + remoteIds.Count];
|
|
|
|
var index = 0;
|
|
|
|
foreach (var id in localIds)
|
|
|
|
{
|
|
|
|
all[index++] = libraryManager.GetItemById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var id in remoteIds)
|
|
|
|
{
|
|
|
|
all[index++] = libraryManager.GetItemById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return all;
|
|
|
|
}
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
}
|