jellyfin/MediaBrowser.Api/Movies/TrailersService.cs

80 lines
2.7 KiB
C#
Raw Normal View History

2013-09-04 17:02:19 +00:00
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
2014-07-02 18:34:08 +00:00
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence;
2013-12-07 15:52:38 +00:00
using ServiceStack;
namespace MediaBrowser.Api.Movies
{
/// <summary>
/// Class GetSimilarTrailers
/// </summary>
2014-03-25 21:13:55 +00:00
[Route("/Trailers/{Id}/Similar", "GET", Summary = "Finds movies and trailers similar to a given trailer.")]
2013-08-09 15:55:22 +00:00
public class GetSimilarTrailers : BaseGetSimilarItemsFromItem
{
}
/// <summary>
/// Class TrailersService
/// </summary>
2014-07-02 18:34:08 +00:00
[Authenticated]
public class TrailersService : BaseApiService
{
/// <summary>
/// The _user manager
/// </summary>
private readonly IUserManager _userManager;
/// <summary>
/// The _user data repository
/// </summary>
2013-10-02 16:08:58 +00:00
private readonly IUserDataManager _userDataRepository;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
2013-06-18 19:16:27 +00:00
private readonly IItemRepository _itemRepo;
2013-09-04 17:02:19 +00:00
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>
2013-10-02 16:08:58 +00:00
public TrailersService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
2013-06-18 19:16:27 +00:00
_itemRepo = itemRepo;
2013-09-04 17:02:19 +00:00
_dtoService = dtoService;
}
/// <summary>
/// Gets the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
public object Get(GetSimilarTrailers request)
{
2013-08-08 20:18:05 +00:00
var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager,
2013-06-18 19:16:27 +00:00
_itemRepo,
_libraryManager,
_userDataRepository,
2013-09-04 17:02:19 +00:00
_dtoService,
Logger,
2014-03-19 04:59:45 +00:00
// Strip out secondary versions
request, item => (item is Movie || item is Trailer) && !((Video)item).PrimaryVersionId.HasValue,
SimilarItemsHelper.GetSimiliarityScore);
return ToOptimizedSerializedResultUsingCache(result);
}
}
}