mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-08 20:38:24 +02:00
77 lines
2.6 KiB
C#
77 lines
2.6 KiB
C#
using MediaBrowser.Controller.Dto;
|
|
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Controller.Persistence;
|
|
using ServiceStack;
|
|
|
|
namespace MediaBrowser.Api.Movies
|
|
{
|
|
/// <summary>
|
|
/// Class GetSimilarTrailers
|
|
/// </summary>
|
|
[Route("/Trailers/{Id}/Similar", "GET", Summary = "Finds movies and trailers similar to a given trailer.")]
|
|
public class GetSimilarTrailers : BaseGetSimilarItemsFromItem
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Class TrailersService
|
|
/// </summary>
|
|
public class TrailersService : BaseApiService
|
|
{
|
|
/// <summary>
|
|
/// The _user manager
|
|
/// </summary>
|
|
private readonly IUserManager _userManager;
|
|
|
|
/// <summary>
|
|
/// The _user data repository
|
|
/// </summary>
|
|
private readonly IUserDataManager _userDataRepository;
|
|
/// <summary>
|
|
/// The _library manager
|
|
/// </summary>
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
private readonly IItemRepository _itemRepo;
|
|
private readonly IDtoService _dtoService;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="TrailersService"/> class.
|
|
/// </summary>
|
|
/// <param name="userManager">The user manager.</param>
|
|
/// <param name="userDataRepository">The user data repository.</param>
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
public TrailersService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
|
|
{
|
|
_userManager = userManager;
|
|
_userDataRepository = userDataRepository;
|
|
_libraryManager = libraryManager;
|
|
_itemRepo = itemRepo;
|
|
_dtoService = dtoService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the specified request.
|
|
/// </summary>
|
|
/// <param name="request">The request.</param>
|
|
/// <returns>System.Object.</returns>
|
|
public object Get(GetSimilarTrailers request)
|
|
{
|
|
var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager,
|
|
_itemRepo,
|
|
_libraryManager,
|
|
_userDataRepository,
|
|
_dtoService,
|
|
Logger,
|
|
|
|
// Strip out secondary versions
|
|
request, item => (item is Movie || item is Trailer) && !((Video)item).PrimaryVersionId.HasValue,
|
|
|
|
SimilarItemsHelper.GetSimiliarityScore);
|
|
|
|
return ToOptimizedSerializedResultUsingCache(result);
|
|
}
|
|
}
|
|
}
|