jellyfin-server/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
LukePulverenti Luke Pulverenti luke pulverenti f1e668bad8 More code cleanups
2012-09-11 15:37:14 -04:00

47 lines
1.4 KiB
C#

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))]
public class MovieSpecialFeaturesHandler : BaseSerializationHandler<DtoBaseItem[]>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("MovieSpecialFeatures", request);
}
protected override Task<DtoBaseItem[]> GetObjectToSerialize()
{
User user = ApiService.GetUserById(QueryString["userid"], true);
var movie = ApiService.GetItemById(ItemId) as Movie;
// If none
if (movie.SpecialFeatures == null)
{
return Task.FromResult(new DtoBaseItem[] { });
}
return Task.WhenAll(movie.SpecialFeatures.Select(i => ApiService.GetDtoBaseItem(i, user, includeChildren: false)));
}
protected string ItemId
{
get
{
return QueryString["id"];
}
}
}
}