jellyfin/MediaBrowser.Api/Movies/TrailersService.cs

90 lines
2.9 KiB
C#
Raw Normal View History

using MediaBrowser.Api.UserLibrary;
using MediaBrowser.Controller.Configuration;
2014-10-20 22:23:40 +02:00
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
2014-07-02 20:34:08 +02:00
using MediaBrowser.Controller.Net;
2017-08-19 21:43:35 +02:00
using MediaBrowser.Model.Dto;
2016-10-24 04:45:23 +02:00
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Querying;
2016-03-20 04:38:02 +01:00
using MediaBrowser.Model.Serialization;
2016-10-25 21:02:04 +02:00
using MediaBrowser.Model.Services;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Movies
{
2014-10-20 22:23:40 +02:00
[Route("/Trailers", "GET", Summary = "Finds movies and trailers similar to a given trailer.")]
2017-08-19 21:43:35 +02:00
public class Getrailers : BaseItemsRequest, IReturn<QueryResult<BaseItemDto>>
2014-10-20 22:23:40 +02:00
{
}
/// <summary>
/// Class TrailersService
/// </summary>
2014-07-02 20:34:08 +02:00
[Authenticated]
public class TrailersService : BaseApiService
{
/// <summary>
/// The _user manager
/// </summary>
private readonly IUserManager _userManager;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
/// <summary>
/// The logger for the created <see cref="ItemsService"/> instances.
/// </summary>
private readonly ILogger<ItemsService> _logger;
2013-09-04 19:02:19 +02:00
private readonly IDtoService _dtoService;
2016-03-20 04:38:02 +01:00
private readonly ILocalizationManager _localizationManager;
private readonly IJsonSerializer _json;
2016-11-10 15:41:24 +01:00
private readonly IAuthorizationContext _authContext;
2013-09-04 19:02:19 +02:00
public TrailersService(
ILoggerFactory loggerFactory,
IServerConfigurationManager serverConfigurationManager,
IHttpResultFactory httpResultFactory,
IUserManager userManager,
ILibraryManager libraryManager,
IDtoService dtoService,
ILocalizationManager localizationManager,
IJsonSerializer json,
IAuthorizationContext authContext)
: base(loggerFactory.CreateLogger<TrailersService>(), serverConfigurationManager, httpResultFactory)
{
_userManager = userManager;
_libraryManager = libraryManager;
2013-09-04 19:02:19 +02:00
_dtoService = dtoService;
2016-03-20 04:38:02 +01:00
_localizationManager = localizationManager;
_json = json;
2016-11-10 15:41:24 +01:00
_authContext = authContext;
_logger = loggerFactory.CreateLogger<ItemsService>();
}
2016-03-20 04:38:02 +01:00
public object Get(Getrailers request)
2014-10-20 22:23:40 +02:00
{
2016-03-20 04:38:02 +01:00
var json = _json.SerializeToString(request);
var getItems = _json.DeserializeFromString<GetItems>(json);
2014-10-20 22:23:40 +02:00
2016-03-20 04:38:02 +01:00
getItems.IncludeItemTypes = "Trailer";
2014-10-20 22:23:40 +02:00
return new ItemsService(
_logger,
ServerConfigurationManager,
ResultFactory,
_userManager,
_libraryManager,
_localizationManager,
_dtoService,
_authContext)
2014-10-20 22:23:40 +02:00
{
2016-03-20 04:38:02 +01:00
Request = Request,
2014-10-20 22:23:40 +02:00
2016-03-20 04:38:02 +01:00
}.Get(getItems);
2014-10-20 22:23:40 +02:00
}
}
}