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 { /// /// Class GetSimilarTrailers /// [Route("/Trailers/{Id}/Similar", "GET")] [Api(Description = "Finds movies and trailers similar to a given trailer.")] public class GetSimilarTrailers : BaseGetSimilarItemsFromItem { } /// /// Class TrailersService /// public class TrailersService : BaseApiService { /// /// The _user manager /// private readonly IUserManager _userManager; /// /// The _user data repository /// private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// private readonly ILibraryManager _libraryManager; private readonly IItemRepository _itemRepo; private readonly IDtoService _dtoService; /// /// Initializes a new instance of the class. /// /// The user manager. /// The user data repository. /// The library manager. public TrailersService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; _libraryManager = libraryManager; _itemRepo = itemRepo; _dtoService = dtoService; } /// /// Gets the specified request. /// /// The request. /// System.Object. public object Get(GetSimilarTrailers request) { var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, _itemRepo, _libraryManager, _userDataRepository, _dtoService, Logger, request, item => item is Movie || item is Trailer, SimilarItemsHelper.GetSimiliarityScore); return ToOptimizedSerializedResultUsingCache(result); } } }