jellyfin/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs

50 lines
1.4 KiB
C#
Raw Normal View History

using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Model.DTO;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
/// <summary>
/// This handler retrieves special features for movies
/// </summary>
[Export(typeof(BaseHandler))]
2012-09-11 18:20:12 +00:00
public class MovieSpecialFeaturesHandler : BaseSerializationHandler<DtoBaseItem[]>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("MovieSpecialFeatures", request);
}
2012-09-11 18:20:12 +00:00
protected override Task<DtoBaseItem[]> GetObjectToSerialize()
{
User user = ApiService.GetUserById(QueryString["userid"], true);
Movie movie = ApiService.GetItemById(ItemId) as Movie;
// If none
if (movie.SpecialFeatures == null)
{
2012-09-11 18:20:12 +00:00
return Task.FromResult(new DtoBaseItem[] { });
}
2012-09-11 18:20:12 +00:00
return Task.WhenAll(movie.SpecialFeatures.Select(i =>
{
2012-09-11 18:20:12 +00:00
return ApiService.GetDtoBaseItem(i, user, includeChildren: false);
}));
}
protected string ItemId
{
get
{
return QueryString["id"];
}
}
}
}