mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-17 11:43:44 +01:00
All calls to get items now require passing in a userId. Made the model project portable. Also filled in more api calls.
This commit is contained in:
parent
baedafbeb9
commit
6fbd5cf464
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Api;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
@@ -21,7 +21,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
|
||||
return ApiService.GetItemsWithGenre(parent, QueryString["name"]);
|
||||
return Kernel.Instance.GetItemsWithGenre(parent, QueryString["name"], UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using System;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net.Handlers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
@@ -16,8 +17,9 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
get
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
||||
return ApiService.GetAllGenres(parent);
|
||||
return ApiService.GetAllGenres(parent, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
@@ -174,7 +175,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
|
||||
if (!string.IsNullOrEmpty(personName))
|
||||
{
|
||||
item = ApiService.GetPersonByName(personName);
|
||||
item = Kernel.Instance.ItemController.GetPerson(personName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
@@ -17,7 +18,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
|
||||
return ApiService.GetInProgressItems(parent);
|
||||
return Kernel.Instance.GetInProgressItems(parent, UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using System;
|
||||
using MediaBrowser.Api.Model;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net.Handlers;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Common.Json;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
@@ -16,26 +18,31 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetSerializationObject(ItemToSerialize, true);
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
||||
return GetSerializationObject(ItemToSerialize, true, userId);
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetSerializationObject(BaseItem item, bool includeChildren)
|
||||
public static object GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
|
||||
{
|
||||
if (includeChildren && item.IsFolder)
|
||||
BaseItemInfo wrapper = new BaseItemInfo()
|
||||
{
|
||||
Folder folder = item as Folder;
|
||||
Item = item,
|
||||
UserItemData = Kernel.Instance.GetUserItemData(userId, item.Id)
|
||||
};
|
||||
|
||||
return new
|
||||
{
|
||||
BaseItem = item,
|
||||
Children = folder.Children
|
||||
};
|
||||
}
|
||||
else
|
||||
if (includeChildren)
|
||||
{
|
||||
return item;
|
||||
var folder = item as Folder;
|
||||
|
||||
if (folder != null)
|
||||
{
|
||||
wrapper.Children = Kernel.Instance.GetParentalAllowedChildren(folder, userId);
|
||||
}
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
protected virtual BaseItem ItemToSerialize
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net.Handlers;
|
||||
@@ -19,7 +20,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
return ItemsToSerialize.Select(i =>
|
||||
{
|
||||
return ItemHandler.GetSerializationObject(i, false);
|
||||
return ItemHandler.GetSerializationObject(i, false, UserId);
|
||||
|
||||
});
|
||||
}
|
||||
@@ -29,5 +30,13 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
protected Guid UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Guid.Parse(QueryString["userid"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
@@ -14,7 +15,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
get
|
||||
{
|
||||
return ApiService.GetPersonByName(QueryString["name"]);
|
||||
return Kernel.Instance.ItemController.GetPerson(QueryString["name"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
@@ -19,10 +20,10 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
|
||||
if (QueryString["unplayed"] == "1")
|
||||
{
|
||||
return ApiService.GetRecentlyAddedUnplayedItems(parent);
|
||||
return Kernel.Instance.GetRecentlyAddedUnplayedItems(parent, UserId);
|
||||
}
|
||||
|
||||
return ApiService.GetRecentlyAddedItems(parent);
|
||||
return Kernel.Instance.GetRecentlyAddedItems(parent, UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
28
MediaBrowser.Api/HttpHandlers/StudioHandler.cs
Normal file
28
MediaBrowser.Api/HttpHandlers/StudioHandler.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all items within containing a studio
|
||||
/// </summary>
|
||||
public class StudioHandler : ItemListHandler
|
||||
{
|
||||
public StudioHandler(RequestContext ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IEnumerable<BaseItem> ItemsToSerialize
|
||||
{
|
||||
get
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
|
||||
return Kernel.Instance.GetItemsWithStudio(parent, QueryString["name"], UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
Normal file
26
MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net.Handlers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
public class StudiosHandler : JsonHandler
|
||||
{
|
||||
public StudiosHandler(RequestContext ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override object ObjectToSerialize
|
||||
{
|
||||
get
|
||||
{
|
||||
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
|
||||
Guid userId = Guid.Parse(QueryString["userid"]);
|
||||
|
||||
return ApiService.GetAllStudios(parent, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
MediaBrowser.Api/HttpHandlers/UsersHandler.cs
Normal file
22
MediaBrowser.Api/HttpHandlers/UsersHandler.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net.Handlers;
|
||||
using MediaBrowser.Controller;
|
||||
|
||||
namespace MediaBrowser.Api.HttpHandlers
|
||||
{
|
||||
class UsersHandler : JsonHandler
|
||||
{
|
||||
public UsersHandler(RequestContext ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
protected override object ObjectToSerialize
|
||||
{
|
||||
get
|
||||
{
|
||||
return Kernel.Instance.Users;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user