Added api methods to get movie special features
This commit is contained in:
parent
29cdf55e44
commit
f68137ec4a
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Entities.Movies;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
|
@ -237,6 +238,19 @@ namespace MediaBrowser.Api
|
|||
Status = series.Status
|
||||
};
|
||||
}
|
||||
|
||||
// Add MovieInfo
|
||||
Movie movie = item as Movie;
|
||||
|
||||
if (movie != null)
|
||||
{
|
||||
int specialFeatureCount = movie.SpecialFeatures == null ? 0 : movie.SpecialFeatures.Count();
|
||||
|
||||
dto.MovieInfo = new MovieInfo()
|
||||
{
|
||||
SpecialFeatureCount = specialFeatureCount
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
49
MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
Normal file
49
MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
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
|
||||
{
|
||||
/// <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);
|
||||
|
||||
Movie movie = ApiService.GetItemById(ItemId) as Movie;
|
||||
|
||||
// If none
|
||||
if (movie.SpecialFeatures == null)
|
||||
{
|
||||
return Task.FromResult<DTOBaseItem[]>(new DTOBaseItem[] { });
|
||||
}
|
||||
|
||||
return Task.WhenAll<DTOBaseItem>(movie.SpecialFeatures.Select(i =>
|
||||
{
|
||||
return ApiService.GetDTOBaseItem(i, user, includeChildren: false, includePeople: true);
|
||||
}));
|
||||
}
|
||||
|
||||
protected string ItemId
|
||||
{
|
||||
get
|
||||
{
|
||||
return QueryString["id"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@
|
|||
<Compile Include="HttpHandlers\AudioHandler.cs" />
|
||||
<Compile Include="HttpHandlers\BaseMediaHandler.cs" />
|
||||
<Compile Include="HttpHandlers\FavoriteStatusHandler.cs" />
|
||||
<Compile Include="HttpHandlers\MovieSpecialFeaturesHandler.cs" />
|
||||
<Compile Include="HttpHandlers\UserHandler.cs" />
|
||||
<Compile Include="HttpHandlers\GenreHandler.cs" />
|
||||
<Compile Include="HttpHandlers\GenresHandler.cs" />
|
||||
|
|
|
@ -367,6 +367,17 @@ namespace MediaBrowser.ApiInteraction.Portable
|
|||
GetDataAsync(url, callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets special features for a Movie
|
||||
/// </summary>
|
||||
public void GetMovieSpecialFeaturesAsync(Guid itemId, Guid userId, Action<DTOBaseItem[]> callback)
|
||||
{
|
||||
string url = ApiUrl + "/MovieSpecialFeatures?id=" + itemId;
|
||||
url += "&userid=" + userId;
|
||||
|
||||
GetDataAsync(url, callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticates a user and returns the result
|
||||
/// </summary>
|
||||
|
|
|
@ -450,6 +450,20 @@ namespace MediaBrowser.ApiInteraction
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets special features for a Movie
|
||||
/// </summary>
|
||||
public async Task<DTOBaseItem[]> GetMovieSpecialFeaturesAsync(Guid itemId, Guid userId)
|
||||
{
|
||||
string url = ApiUrl + "/MovieSpecialFeatures?id=" + itemId;
|
||||
url += "&userid=" + userId;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return DeserializeFromStream<DTOBaseItem[]>(stream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a user's favorite status for an item and returns the updated UserItemData object.
|
||||
/// </summary>
|
||||
|
|
|
@ -160,6 +160,9 @@ namespace MediaBrowser.Model.DTO
|
|||
public SeriesInfo SeriesInfo { get; set; }
|
||||
|
||||
[ProtoMember(45)]
|
||||
public MovieInfo MovieInfo { get; set; }
|
||||
|
||||
[ProtoMember(46)]
|
||||
public bool IsNew { get; set; }
|
||||
|
||||
public bool IsType(Type type)
|
||||
|
|
11
MediaBrowser.Model/DTO/MovieInfo.cs
Normal file
11
MediaBrowser.Model/DTO/MovieInfo.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using ProtoBuf;
|
||||
|
||||
namespace MediaBrowser.Model.DTO
|
||||
{
|
||||
[ProtoContract]
|
||||
public class MovieInfo
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public int SpecialFeatureCount { get; set; }
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@
|
|||
<Compile Include="DTO\AudioInfo.cs" />
|
||||
<Compile Include="DTO\AudioOutputFormats.cs" />
|
||||
<Compile Include="DTO\DTOUserItemData.cs" />
|
||||
<Compile Include="DTO\MovieInfo.cs" />
|
||||
<Compile Include="DTO\SeriesInfo.cs" />
|
||||
<Compile Include="Authentication\AuthenticationResult.cs" />
|
||||
<Compile Include="DTO\DTOBaseItem.cs" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user