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