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