jellyfin/MediaBrowser.Api/Movies/TrailersService.cs

72 lines
2.5 KiB
C#
Raw Normal View History

2014-10-20 13:23:40 -07:00
using MediaBrowser.Api.UserLibrary;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
2014-07-02 11:34:08 -07:00
using MediaBrowser.Controller.Net;
2014-10-20 13:23:40 -07:00
using MediaBrowser.Model.Querying;
2016-03-19 20:38:02 -07:00
using MediaBrowser.Controller.Collections;
2017-08-19 12:43:35 -07:00
using MediaBrowser.Model.Dto;
2016-10-23 19:45:23 -07:00
using MediaBrowser.Model.Globalization;
2016-03-19 20:38:02 -07:00
using MediaBrowser.Model.Serialization;
2016-10-25 12:02:04 -07:00
using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Movies
{
2014-10-20 13:23:40 -07:00
[Route("/Trailers", "GET", Summary = "Finds movies and trailers similar to a given trailer.")]
2017-08-19 12:43:35 -07:00
public class Getrailers : BaseItemsRequest, IReturn<QueryResult<BaseItemDto>>
2014-10-20 13:23:40 -07:00
{
}
/// <summary>
/// Class TrailersService
/// </summary>
2014-07-02 11:34:08 -07:00
[Authenticated]
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;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
2013-09-04 10:02:19 -07:00
private readonly IDtoService _dtoService;
2016-03-19 20:38:02 -07:00
private readonly ICollectionManager _collectionManager;
private readonly ILocalizationManager _localizationManager;
private readonly IJsonSerializer _json;
2016-11-10 07:41:24 -07:00
private readonly IAuthorizationContext _authContext;
2013-09-04 10:02:19 -07:00
2016-11-10 07:41:24 -07:00
public TrailersService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IDtoService dtoService, ICollectionManager collectionManager, ILocalizationManager localizationManager, IJsonSerializer json, IAuthorizationContext authContext)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
2013-09-04 10:02:19 -07:00
_dtoService = dtoService;
2016-03-19 20:38:02 -07:00
_collectionManager = collectionManager;
_localizationManager = localizationManager;
_json = json;
2016-11-10 07:41:24 -07:00
_authContext = authContext;
}
2016-03-19 20:38:02 -07:00
public object Get(Getrailers request)
2014-10-20 13:23:40 -07:00
{
2016-03-19 20:38:02 -07:00
var json = _json.SerializeToString(request);
var getItems = _json.DeserializeFromString<GetItems>(json);
2014-10-20 13:23:40 -07:00
2016-03-19 20:38:02 -07:00
getItems.IncludeItemTypes = "Trailer";
2014-10-20 13:23:40 -07:00
2016-11-10 07:41:24 -07:00
return new ItemsService(_userManager, _libraryManager, _localizationManager, _dtoService, _authContext)
2014-10-20 13:23:40 -07:00
{
2016-03-19 20:38:02 -07:00
Request = Request,
2014-10-20 13:23:40 -07:00
2016-03-19 20:38:02 -07:00
}.Get(getItems);
2014-10-20 13:23:40 -07:00
}
}
}