jellyfin/MediaBrowser.Api/HttpHandlers/ItemHandler.cs

57 lines
1.5 KiB
C#
Raw Normal View History

using System;
using MediaBrowser.Api.Model;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
2012-07-12 06:55:27 +00:00
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class ItemHandler : JsonHandler
2012-07-12 06:55:27 +00:00
{
public ItemHandler(RequestContext ctx)
: base(ctx)
{
}
protected sealed override object ObjectToSerialize
2012-07-12 06:55:27 +00:00
{
get
{
Guid userId = Guid.Parse(QueryString["userid"]);
return GetSerializationObject(ItemToSerialize, true, userId);
2012-07-12 06:55:27 +00:00
}
}
public static object GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
2012-07-12 06:55:27 +00:00
{
BaseItemInfo wrapper = new BaseItemInfo()
2012-07-12 06:55:27 +00:00
{
Item = item,
UserItemData = Kernel.Instance.GetUserItemData(userId, item.Id)
};
if (includeChildren)
2012-07-12 06:55:27 +00:00
{
var folder = item as Folder;
if (folder != null)
{
wrapper.Children = Kernel.Instance.GetParentalAllowedChildren(folder, userId);
}
2012-07-12 06:55:27 +00:00
}
return wrapper;
2012-07-12 06:55:27 +00:00
}
protected virtual BaseItem ItemToSerialize
2012-07-12 06:55:27 +00:00
{
get
2012-07-12 06:55:27 +00:00
{
return ApiService.GetItemById(QueryString["id"]);
2012-07-12 06:55:27 +00:00
}
}
}
}