You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
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"];
|
|
}
|
|
}
|
|
}
|
|
}
|