aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-08-17 12:47:35 -0400
committerLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-08-17 12:47:35 -0400
commit5c6ec34a9cff0819957fe5e4278f6e0d1ecc1fa3 (patch)
tree59209813ff9588bcca79a6f32124bac0acad3c1a
parent5c094afd7e79934cb02f29a9a0080ed12c7e1098 (diff)
Consolidated handlers that return lists of items. Renamed ApiBaseItemWrapper to ApiBaseItemContainer. Added Person and Studio DTO's to BaseItemWrapper
-rw-r--r--MediaBrowser.Api/ApiService.cs44
-rw-r--r--MediaBrowser.Api/HttpHandlers/GenresHandler.cs4
-rw-r--r--MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs19
-rw-r--r--MediaBrowser.Api/HttpHandlers/ItemHandler.cs4
-rw-r--r--MediaBrowser.Api/HttpHandlers/ItemListHandler.cs59
-rw-r--r--MediaBrowser.Api/HttpHandlers/ItemsWithGenreHandler.cs22
-rw-r--r--MediaBrowser.Api/HttpHandlers/ItemsWithPersonHandler.cs32
-rw-r--r--MediaBrowser.Api/HttpHandlers/ItemsWithStudioHandler.cs22
-rw-r--r--MediaBrowser.Api/HttpHandlers/ItemsWithYearHandler.cs22
-rw-r--r--MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs24
-rw-r--r--MediaBrowser.Api/HttpHandlers/StudiosHandler.cs4
-rw-r--r--MediaBrowser.Api/HttpHandlers/UserConfigurationHandler.cs17
-rw-r--r--MediaBrowser.Api/HttpHandlers/YearsHandler.cs4
-rw-r--r--MediaBrowser.Api/MediaBrowser.Api.csproj7
-rw-r--r--MediaBrowser.Api/Plugin.cs28
-rw-r--r--MediaBrowser.ApiInteraction/ApiClient.cs58
-rw-r--r--MediaBrowser.Controller/Configuration/ServerConfiguration.cs27
-rw-r--r--MediaBrowser.Controller/Kernel.cs34
-rw-r--r--MediaBrowser.Model/Configuration/UserConfiguration.cs16
-rw-r--r--MediaBrowser.Model/DTO/ApiBaseItem.cs13
-rw-r--r--MediaBrowser.Model/DTO/CategoryInfo.cs19
-rw-r--r--MediaBrowser.Model/DTO/IBNItem.cs38
-rw-r--r--MediaBrowser.Model/Entities/Person.cs1
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj3
-rw-r--r--MediaBrowser.Model/Users/User.cs7
25 files changed, 195 insertions, 333 deletions
diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs
index e4a7f71bf..25a7ff9ec 100644
--- a/MediaBrowser.Api/ApiService.cs
+++ b/MediaBrowser.Api/ApiService.cs
@@ -24,9 +24,9 @@ namespace MediaBrowser.Api
/// <summary>
/// Takes a BaseItem and returns the actual object that will be serialized by the api
/// </summary>
- public static BaseItemWrapper<BaseItem> GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
+ public static BaseItemContainer<BaseItem> GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
{
- BaseItemWrapper<BaseItem> wrapper = new BaseItemWrapper<BaseItem>()
+ BaseItemContainer<BaseItem> wrapper = new BaseItemContainer<BaseItem>()
{
Item = item,
UserItemData = Kernel.Instance.GetUserItemData(userId, item.Id),
@@ -60,7 +60,45 @@ namespace MediaBrowser.Api
wrapper.Children = Kernel.Instance.GetParentalAllowedChildren(folder, userId).Select(c => GetSerializationObject(c, false, userId));
}
- wrapper.People = item.People;
+ // Attach People by transforming them into BaseItemPerson (DTO)
+ if (item.People != null)
+ {
+ wrapper.People = item.People.Select(p =>
+ {
+ BaseItemPerson baseItemPerson = new BaseItemPerson();
+
+ baseItemPerson.PersonInfo = p;
+
+ Person ibnObject = Kernel.Instance.ItemController.GetPerson(p.Name);
+
+ if (ibnObject != null)
+ {
+ baseItemPerson.PrimaryImagePath = ibnObject.PrimaryImagePath;
+ }
+
+ return baseItemPerson;
+ });
+ }
+ }
+
+ // Attach Studios by transforming them into BaseItemStudio (DTO)
+ if (item.Studios != null)
+ {
+ wrapper.Studios = item.Studios.Select(s =>
+ {
+ BaseItemStudio baseItemStudio = new BaseItemStudio();
+
+ baseItemStudio.Name = s;
+
+ Studio ibnObject = Kernel.Instance.ItemController.GetStudio(s);
+
+ if (ibnObject != null)
+ {
+ baseItemStudio.PrimaryImagePath = ibnObject.PrimaryImagePath;
+ }
+
+ return baseItemStudio;
+ });
}
return wrapper;
diff --git a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs
index c3292d363..902871fa1 100644
--- a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs
@@ -7,9 +7,9 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
- public class GenresHandler : BaseJsonHandler<IEnumerable<CategoryInfo<Genre>>>
+ public class GenresHandler : BaseJsonHandler<IEnumerable<IBNItem<Genre>>>
{
- protected override IEnumerable<CategoryInfo<Genre>> GetObjectToSerialize()
+ protected override IEnumerable<IBNItem<Genre>> GetObjectToSerialize()
{
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
Guid userId = Guid.Parse(QueryString["userid"]);
diff --git a/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs b/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs
deleted file mode 100644
index 2bee275a4..000000000
--- a/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- class InProgressItemsHandler : ItemListHandler
- {
- protected override IEnumerable<BaseItem> ItemsToSerialize
- {
- get
- {
- Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
-
- return Kernel.Instance.GetInProgressItems(parent, UserId);
- }
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
index efb67db54..3df8e914f 100644
--- a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
@@ -5,9 +5,9 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
- public class ItemHandler : BaseJsonHandler<BaseItemWrapper<BaseItem>>
+ public class ItemHandler : BaseJsonHandler<BaseItemContainer<BaseItem>>
{
- protected sealed override BaseItemWrapper<BaseItem> GetObjectToSerialize()
+ protected sealed override BaseItemContainer<BaseItem> GetObjectToSerialize()
{
Guid userId = Guid.Parse(QueryString["userid"]);
diff --git a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
index 6e08561b2..b3d85687f 100644
--- a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
@@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Common.Net.Handlers;
+using MediaBrowser.Controller;
using MediaBrowser.Model.DTO;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
- public abstract class ItemListHandler : BaseJsonHandler<IEnumerable<BaseItemWrapper<BaseItem>>>
+ public class ItemListHandler : BaseJsonHandler<IEnumerable<BaseItemContainer<BaseItem>>>
{
- protected override IEnumerable<BaseItemWrapper<BaseItem>> GetObjectToSerialize()
+ protected override IEnumerable<BaseItemContainer<BaseItem>> GetObjectToSerialize()
{
return ItemsToSerialize.Select(i =>
{
@@ -18,9 +19,51 @@ namespace MediaBrowser.Api.HttpHandlers
});
}
- protected abstract IEnumerable<BaseItem> ItemsToSerialize
+ protected IEnumerable<BaseItem> ItemsToSerialize
{
- get;
+ get
+ {
+ Folder parent = ApiService.GetItemById(ItemId) as Folder;
+
+ if (ListType.Equals("inprogressitems", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetInProgressItems(parent, UserId);
+ }
+ else if (ListType.Equals("recentlyaddeditems", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetRecentlyAddedItems(parent, UserId);
+ }
+ else if (ListType.Equals("recentlyaddedunplayeditems", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetRecentlyAddedUnplayedItems(parent, UserId);
+ }
+ else if (ListType.Equals("itemswithgenre", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetItemsWithGenre(parent, QueryString["name"], UserId);
+ }
+ else if (ListType.Equals("itemswithyear", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetItemsWithYear(parent, int.Parse(QueryString["year"]), UserId);
+ }
+ else if (ListType.Equals("itemswithstudio", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetItemsWithStudio(parent, QueryString["name"], UserId);
+ }
+ else if (ListType.Equals("itemswithperson", StringComparison.OrdinalIgnoreCase))
+ {
+ return Kernel.Instance.GetItemsWithPerson(parent, QueryString["name"], UserId);
+ }
+
+ throw new InvalidOperationException();
+ }
+ }
+
+ protected string ItemId
+ {
+ get
+ {
+ return QueryString["id"];
+ }
}
protected Guid UserId
@@ -30,5 +73,13 @@ namespace MediaBrowser.Api.HttpHandlers
return Guid.Parse(QueryString["userid"]);
}
}
+
+ private string ListType
+ {
+ get
+ {
+ return QueryString["listtype"] ?? string.Empty;
+ }
+ }
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemsWithGenreHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemsWithGenreHandler.cs
deleted file mode 100644
index 16bb56196..000000000
--- a/MediaBrowser.Api/HttpHandlers/ItemsWithGenreHandler.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- /// <summary>
- /// Gets all items within a Genre
- /// </summary>
- public class ItemsWithGenreHandler : ItemListHandler
- {
- protected override IEnumerable<BaseItem> ItemsToSerialize
- {
- get
- {
- Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
-
- return Kernel.Instance.GetItemsWithGenre(parent, QueryString["name"], UserId);
- }
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemsWithPersonHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemsWithPersonHandler.cs
deleted file mode 100644
index 624abc762..000000000
--- a/MediaBrowser.Api/HttpHandlers/ItemsWithPersonHandler.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- /// <summary>
- /// Gets all items within containing a person
- /// </summary>
- public class ItemsWithPersonHandler : ItemListHandler
- {
- protected override IEnumerable<BaseItem> ItemsToSerialize
- {
- get
- {
- Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
-
- PersonType? personType = null;
-
- string type = QueryString["persontype"];
-
- if (!string.IsNullOrEmpty(type))
- {
- personType = (PersonType)Enum.Parse(typeof(PersonType), type, true);
- }
-
- return Kernel.Instance.GetItemsWithPerson(parent, QueryString["name"], personType, UserId);
- }
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemsWithStudioHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemsWithStudioHandler.cs
deleted file mode 100644
index 30120d524..000000000
--- a/MediaBrowser.Api/HttpHandlers/ItemsWithStudioHandler.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- /// <summary>
- /// Gets all items within containing a studio
- /// </summary>
- public class ItemsWithStudioHandler : ItemListHandler
- {
- protected override IEnumerable<BaseItem> ItemsToSerialize
- {
- get
- {
- Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
-
- return Kernel.Instance.GetItemsWithStudio(parent, QueryString["name"], UserId);
- }
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemsWithYearHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemsWithYearHandler.cs
deleted file mode 100644
index d5d4df444..000000000
--- a/MediaBrowser.Api/HttpHandlers/ItemsWithYearHandler.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- /// <summary>
- /// Gets all items within containing a studio
- /// </summary>
- public class ItemsWithYearHandler : ItemListHandler
- {
- protected override IEnumerable<BaseItem> ItemsToSerialize
- {
- get
- {
- Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
-
- return Kernel.Instance.GetItemsWithYear(parent, int.Parse(QueryString["name"]), UserId);
- }
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs b/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs
deleted file mode 100644
index f36c9c997..000000000
--- a/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- class RecentlyAddedItemsHandler : ItemListHandler
- {
- protected override IEnumerable<BaseItem> ItemsToSerialize
- {
- get
- {
- Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
-
- if (QueryString["unplayed"] == "1")
- {
- return Kernel.Instance.GetRecentlyAddedUnplayedItems(parent, UserId);
- }
-
- return Kernel.Instance.GetRecentlyAddedItems(parent, UserId);
- }
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
index b1be2cad2..b33988b3e 100644
--- a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
@@ -7,9 +7,9 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
- public class StudiosHandler : BaseJsonHandler<IEnumerable<CategoryInfo<Studio>>>
+ public class StudiosHandler : BaseJsonHandler<IEnumerable<IBNItem<Studio>>>
{
- protected override IEnumerable<CategoryInfo<Studio>> GetObjectToSerialize()
+ protected override IEnumerable<IBNItem<Studio>> GetObjectToSerialize()
{
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
Guid userId = Guid.Parse(QueryString["userid"]);
diff --git a/MediaBrowser.Api/HttpHandlers/UserConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/UserConfigurationHandler.cs
deleted file mode 100644
index 12e80f306..000000000
--- a/MediaBrowser.Api/HttpHandlers/UserConfigurationHandler.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using MediaBrowser.Common.Net.Handlers;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Configuration;
-
-namespace MediaBrowser.Api.HttpHandlers
-{
- public class UserConfigurationHandler : BaseJsonHandler<UserConfiguration>
- {
- protected override UserConfiguration GetObjectToSerialize()
- {
- Guid userId = Guid.Parse(QueryString["userid"]);
-
- return Kernel.Instance.GetUserConfiguration(userId);
- }
- }
-}
diff --git a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs
index cc3474880..8a58a2a19 100644
--- a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs
@@ -7,9 +7,9 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
- public class YearsHandler : BaseJsonHandler<IEnumerable<CategoryInfo<Year>>>
+ public class YearsHandler : BaseJsonHandler<IEnumerable<IBNItem<Year>>>
{
- protected override IEnumerable<CategoryInfo<Year>> GetObjectToSerialize()
+ protected override IEnumerable<IBNItem<Year>> GetObjectToSerialize()
{
Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;
Guid userId = Guid.Parse(QueryString["userid"]);
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index e6a1816f6..4b6b6aa1a 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -49,23 +49,16 @@
<Compile Include="ApiService.cs" />
<Compile Include="HttpHandlers\AudioHandler.cs" />
<Compile Include="HttpHandlers\BaseMediaHandler.cs" />
- <Compile Include="HttpHandlers\ItemsWithGenreHandler.cs" />
<Compile Include="HttpHandlers\GenresHandler.cs" />
<Compile Include="HttpHandlers\ImageHandler.cs" />
- <Compile Include="HttpHandlers\InProgressItemsHandler.cs" />
<Compile Include="HttpHandlers\ItemHandler.cs" />
<Compile Include="HttpHandlers\ItemListHandler.cs" />
- <Compile Include="HttpHandlers\ItemsWithPersonHandler.cs" />
<Compile Include="HttpHandlers\PersonHandler.cs" />
<Compile Include="HttpHandlers\PluginConfigurationHandler.cs" />
<Compile Include="HttpHandlers\PluginsHandler.cs" />
- <Compile Include="HttpHandlers\RecentlyAddedItemsHandler.cs" />
- <Compile Include="HttpHandlers\ItemsWithStudioHandler.cs" />
<Compile Include="HttpHandlers\StudiosHandler.cs" />
- <Compile Include="HttpHandlers\UserConfigurationHandler.cs" />
<Compile Include="HttpHandlers\UsersHandler.cs" />
<Compile Include="HttpHandlers\VideoHandler.cs" />
- <Compile Include="HttpHandlers\ItemsWithYearHandler.cs" />
<Compile Include="HttpHandlers\YearsHandler.cs" />
<Compile Include="ImageProcessor.cs" />
<Compile Include="Plugin.cs" />
diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.cs
index 6bfdd5134..659763c5f 100644
--- a/MediaBrowser.Api/Plugin.cs
+++ b/MediaBrowser.Api/Plugin.cs
@@ -49,46 +49,22 @@ namespace MediaBrowser.Api
{
return new UsersHandler();
}
- else if (localPath.EndsWith("/api/itemswithgenre", StringComparison.OrdinalIgnoreCase))
+ else if (localPath.EndsWith("/api/itemlist", StringComparison.OrdinalIgnoreCase))
{
- return new ItemsWithGenreHandler();
+ return new ItemListHandler();
}
else if (localPath.EndsWith("/api/genres", StringComparison.OrdinalIgnoreCase))
{
return new GenresHandler();
}
- else if (localPath.EndsWith("/api/itemswithyear", StringComparison.OrdinalIgnoreCase))
- {
- return new ItemsWithYearHandler();
- }
- else if (localPath.EndsWith("/api/itemswithperson", StringComparison.OrdinalIgnoreCase))
- {
- return new ItemsWithPersonHandler();
- }
else if (localPath.EndsWith("/api/years", StringComparison.OrdinalIgnoreCase))
{
return new YearsHandler();
}
- else if (localPath.EndsWith("/api/itemswithstudio", StringComparison.OrdinalIgnoreCase))
- {
- return new ItemsWithStudioHandler();
- }
else if (localPath.EndsWith("/api/studios", StringComparison.OrdinalIgnoreCase))
{
return new StudiosHandler();
}
- else if (localPath.EndsWith("/api/recentlyaddeditems", StringComparison.OrdinalIgnoreCase))
- {
- return new RecentlyAddedItemsHandler();
- }
- else if (localPath.EndsWith("/api/inprogressitems", StringComparison.OrdinalIgnoreCase))
- {
- return new InProgressItemsHandler();
- }
- else if (localPath.EndsWith("/api/userconfiguration", StringComparison.OrdinalIgnoreCase))
- {
- return new UserConfigurationHandler();
- }
else if (localPath.EndsWith("/api/plugins", StringComparison.OrdinalIgnoreCase))
{
return new PluginsHandler();
diff --git a/MediaBrowser.ApiInteraction/ApiClient.cs b/MediaBrowser.ApiInteraction/ApiClient.cs
index 7818dbdf8..af79513e0 100644
--- a/MediaBrowser.ApiInteraction/ApiClient.cs
+++ b/MediaBrowser.ApiInteraction/ApiClient.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.DTO;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Users;
@@ -91,7 +90,7 @@ namespace MediaBrowser.ApiInteraction
/// <param name="maxWidth">Use if a max width is required. Aspect ratio will be preserved.</param>
/// <param name="maxHeight">Use if a max height is required. Aspect ratio will be preserved.</param>
/// <param name="quality">Quality level, from 0-100. Currently only applies to JPG. The default value should suffice.</param>
- public IEnumerable<string> GetBackdropImageUrls(BaseItemWrapper<ApiBaseItem> itemWrapper, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null)
+ public IEnumerable<string> GetBackdropImageUrls(ApiBaseItemContainer itemWrapper, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null)
{
Guid? backdropItemId = null;
int backdropCount = 0;
@@ -131,7 +130,7 @@ namespace MediaBrowser.ApiInteraction
/// <param name="maxWidth">Use if a max width is required. Aspect ratio will be preserved.</param>
/// <param name="maxHeight">Use if a max height is required. Aspect ratio will be preserved.</param>
/// <param name="quality">Quality level, from 0-100. Currently only applies to JPG. The default value should suffice.</param>
- public string GetLogoImageUrl(BaseItemWrapper<ApiBaseItem> itemWrapper, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null)
+ public string GetLogoImageUrl(ApiBaseItemContainer itemWrapper, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null)
{
Guid? logoItemId = !string.IsNullOrEmpty(itemWrapper.Item.LogoImagePath) ? itemWrapper.Item.Id : itemWrapper.ParentLogoItemId;
@@ -154,7 +153,7 @@ namespace MediaBrowser.ApiInteraction
/// <summary>
/// Gets a BaseItem
/// </summary>
- public async Task<BaseItemWrapper<ApiBaseItem>> GetItemAsync(Guid id, Guid userId)
+ public async Task<ApiBaseItemContainer> GetItemAsync(Guid id, Guid userId)
{
string url = ApiUrl + "/item?userId=" + userId.ToString();
@@ -165,7 +164,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<BaseItemWrapper<ApiBaseItem>>(stream);
+ return JsonSerializer.DeserializeFromStream<ApiBaseItemContainer>(stream);
}
}
@@ -185,61 +184,61 @@ namespace MediaBrowser.ApiInteraction
/// <summary>
/// Gets all Genres
/// </summary>
- public async Task<IEnumerable<CategoryInfo<Genre>>> GetAllGenresAsync(Guid userId)
+ public async Task<IEnumerable<IBNItem<Genre>>> GetAllGenresAsync(Guid userId)
{
string url = ApiUrl + "/genres?userId=" + userId.ToString();
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<CategoryInfo<Genre>>>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<IBNItem<Genre>>>(stream);
}
}
/// <summary>
/// Gets all Years
/// </summary>
- public async Task<IEnumerable<CategoryInfo<Year>>> GetAllYearsAsync(Guid userId)
+ public async Task<IEnumerable<IBNItem<Year>>> GetAllYearsAsync(Guid userId)
{
string url = ApiUrl + "/years?userId=" + userId.ToString();
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<CategoryInfo<Year>>>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<IBNItem<Year>>>(stream);
}
}
/// <summary>
/// Gets all items that contain a given Year
/// </summary>
- public async Task<IEnumerable<BaseItemWrapper<ApiBaseItem>>> GetItemsWithYearAsync(string name, Guid userId)
+ public async Task<IEnumerable<ApiBaseItemContainer>> GetItemsWithYearAsync(string name, Guid userId)
{
- string url = ApiUrl + "/itemswithyear?userId=" + userId.ToString() + "&name=" + name;
+ string url = ApiUrl + "/itemlist?listtype=itemswithyear&userId=" + userId.ToString() + "&name=" + name;
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<BaseItemWrapper<ApiBaseItem>>>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<ApiBaseItemContainer>>(stream);
}
}
/// <summary>
/// Gets all items that contain a given Genre
/// </summary>
- public async Task<IEnumerable<BaseItemWrapper<ApiBaseItem>>> GetItemsWithGenreAsync(string name, Guid userId)
+ public async Task<IEnumerable<ApiBaseItemContainer>> GetItemsWithGenreAsync(string name, Guid userId)
{
- string url = ApiUrl + "/itemswithgenre?userId=" + userId.ToString() + "&name=" + name;
+ string url = ApiUrl + "/itemlist?listtype=itemswithgenre&userId=" + userId.ToString() + "&name=" + name;
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<BaseItemWrapper<ApiBaseItem>>>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<ApiBaseItemContainer>>(stream);
}
}
/// <summary>
/// Gets all items that contain a given Person
/// </summary>
- public async Task<IEnumerable<BaseItemWrapper<ApiBaseItem>>> GetItemsWithPersonAsync(string name, PersonType? personType, Guid userId)
+ public async Task<IEnumerable<ApiBaseItemContainer>> GetItemsWithPersonAsync(string name, PersonType? personType, Guid userId)
{
- string url = ApiUrl + "/itemswithperson?userId=" + userId.ToString() + "&name=" + name;
+ string url = ApiUrl + "/itemlist?listtype=itemswithperson&userId=" + userId.ToString() + "&name=" + name;
if (personType.HasValue)
{
@@ -248,46 +247,33 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<BaseItemWrapper<ApiBaseItem>>>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<ApiBaseItemContainer>>(stream);
}
}
/// <summary>
/// Gets all studious
/// </summary>
- public async Task<IEnumerable<CategoryInfo<Studio>>> GetAllStudiosAsync(Guid userId)
+ public async Task<IEnumerable<IBNItem<Studio>>> GetAllStudiosAsync(Guid userId)
{
string url = ApiUrl + "/studios?userId=" + userId.ToString();
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<CategoryInfo<Studio>>>(stream);
- }
- }
-
- /// <summary>
- /// Gets the current personalized configuration
- /// </summary>
- public async Task<UserConfiguration> GetUserConfigurationAsync(Guid userId)
- {
- string url = ApiUrl + "/userconfiguration?userId=" + userId.ToString();
-
- using (Stream stream = await HttpClient.GetStreamAsync(url))
- {
- return JsonSerializer.DeserializeFromStream<UserConfiguration>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<IBNItem<Studio>>>(stream);
}
}
/// <summary>
/// Gets all items that contain a given Studio
/// </summary>
- public async Task<IEnumerable<BaseItemWrapper<ApiBaseItem>>> GetItemsWithStudioAsync(string name, Guid userId)
+ public async Task<IEnumerable<ApiBaseItemContainer>> GetItemsWithStudioAsync(string name, Guid userId)
{
- string url = ApiUrl + "/itemswithstudio?userId=" + userId.ToString() + "&name=" + name;
+ string url = ApiUrl + "/itemlist?listtype=itemswithstudio&userId=" + userId.ToString() + "&name=" + name;
using (Stream stream = await HttpClient.GetStreamAsync(url))
{
- return JsonSerializer.DeserializeFromStream<IEnumerable<BaseItemWrapper<ApiBaseItem>>>(stream);
+ return JsonSerializer.DeserializeFromStream<IEnumerable<ApiBaseItemContainer>>(stream);
}
}
diff --git a/MediaBrowser.Controller/Configuration/ServerConfiguration.cs b/MediaBrowser.Controller/Configuration/ServerConfiguration.cs
index 56f3a854f..88d1012b1 100644
--- a/MediaBrowser.Controller/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Controller/Configuration/ServerConfiguration.cs
@@ -1,37 +1,10 @@
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
-using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Controller.Configuration
{
public class ServerConfiguration : BaseApplicationConfiguration
{
public string ImagesByNamePath { get; set; }
-
- /// <summary>
- /// Gets or sets the default UI configuration
- /// </summary>
- public UserConfiguration DefaultUserConfiguration { get; set; }
-
- /// <summary>
- /// Gets or sets a list of registered UI device names
- /// </summary>
- public List<string> DeviceNames { get; set; }
-
- /// <summary>
- /// Gets or sets all available UIConfigurations
- /// The key contains device name and user id
- /// </summary>
- public Dictionary<string, UserConfiguration> UserConfigurations { get; set; }
-
- public ServerConfiguration()
- : base()
- {
- DefaultUserConfiguration = new UserConfiguration();
-
- UserConfigurations = new Dictionary<string, UserConfiguration>();
-
- DeviceNames = new List<string>();
- }
}
}
diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs
index ef9a07814..375b11a59 100644
--- a/MediaBrowser.Controller/Kernel.cs
+++ b/MediaBrowser.Controller/Kernel.cs
@@ -12,7 +12,6 @@ using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
-using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.DTO;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Progress;
@@ -155,11 +154,6 @@ namespace MediaBrowser.Controller
}
}
- public UserConfiguration GetUserConfiguration(Guid userId)
- {
- return Configuration.DefaultUserConfiguration;
- }
-
public void ReloadItem(BaseItem item)
{
Folder folder = item as Folder;
@@ -263,9 +257,9 @@ namespace MediaBrowser.Controller
{
DateTime now = DateTime.Now;
- UserConfiguration config = GetUserConfiguration(userId);
+ User user = Users.First(u => u.Id == userId);
- return GetParentalAllowedRecursiveChildren(parent, userId).Where(i => !(i is Folder) && (now - i.DateCreated).TotalDays < config.RecentItemDays);
+ return GetParentalAllowedRecursiveChildren(parent, userId).Where(i => !(i is Folder) && (now - i.DateCreated).TotalDays < user.RecentItemDays);
}
/// <summary>
@@ -358,7 +352,7 @@ namespace MediaBrowser.Controller
/// Gets all years from all recursive children of a folder
/// The CategoryInfo class is used to keep track of the number of times each year appears
/// </summary>
- public IEnumerable<CategoryInfo<Year>> GetAllYears(Folder parent, Guid userId)
+ public IEnumerable<IBNItem<Year>> GetAllYears(Folder parent, Guid userId)
{
Dictionary<int, int> data = new Dictionary<int, int>();
@@ -385,7 +379,7 @@ namespace MediaBrowser.Controller
}
// Now go through the dictionary and create a Category for each studio
- List<CategoryInfo<Year>> list = new List<CategoryInfo<Year>>();
+ List<IBNItem<Year>> list = new List<IBNItem<Year>>();
foreach (int key in data.Keys)
{
@@ -394,10 +388,10 @@ namespace MediaBrowser.Controller
if (entity != null)
{
- list.Add(new CategoryInfo<Year>()
+ list.Add(new IBNItem<Year>()
{
Item = entity,
- ItemCount = data[key]
+ BaseItemCount = data[key]
});
}
}
@@ -409,7 +403,7 @@ namespace MediaBrowser.Controller
/// Gets all studios from all recursive children of a folder
/// The CategoryInfo class is used to keep track of the number of times each studio appears
/// </summary>
- public IEnumerable<CategoryInfo<Studio>> GetAllStudios(Folder parent, Guid userId)
+ public IEnumerable<IBNItem<Studio>> GetAllStudios(Folder parent, Guid userId)
{
Dictionary<string, int> data = new Dictionary<string, int>();
@@ -439,7 +433,7 @@ namespace MediaBrowser.Controller
}
// Now go through the dictionary and create a Category for each studio
- List<CategoryInfo<Studio>> list = new List<CategoryInfo<Studio>>();
+ List<IBNItem<Studio>> list = new List<IBNItem<Studio>>();
foreach (string key in data.Keys)
{
@@ -448,10 +442,10 @@ namespace MediaBrowser.Controller
if (entity != null)
{
- list.Add(new CategoryInfo<Studio>()
+ list.Add(new IBNItem<Studio>()
{
Item = entity,
- ItemCount = data[key]
+ BaseItemCount = data[key]
});
}
}
@@ -463,7 +457,7 @@ namespace MediaBrowser.Controller
/// Gets all genres from all recursive children of a folder
/// The CategoryInfo class is used to keep track of the number of times each genres appears
/// </summary>
- public IEnumerable<CategoryInfo<Genre>> GetAllGenres(Folder parent, Guid userId)
+ public IEnumerable<IBNItem<Genre>> GetAllGenres(Folder parent, Guid userId)
{
Dictionary<string, int> data = new Dictionary<string, int>();
@@ -493,7 +487,7 @@ namespace MediaBrowser.Controller
}
// Now go through the dictionary and create a Category for each genre
- List<CategoryInfo<Genre>> list = new List<CategoryInfo<Genre>>();
+ List<IBNItem<Genre>> list = new List<IBNItem<Genre>>();
foreach (string key in data.Keys)
{
@@ -502,10 +496,10 @@ namespace MediaBrowser.Controller
if (entity != null)
{
- list.Add(new CategoryInfo<Genre>()
+ list.Add(new IBNItem<Genre>()
{
Item = entity,
- ItemCount = data[key]
+ BaseItemCount = data[key]
});
}
}
diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs
deleted file mode 100644
index 5616f6dd6..000000000
--- a/MediaBrowser.Model/Configuration/UserConfiguration.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-
-namespace MediaBrowser.Model.Configuration
-{
- /// <summary>
- /// This holds settings that can be personalized on a per-user, per-device basis.
- /// </summary>
- public class UserConfiguration
- {
- public int RecentItemDays { get; set; }
-
- public UserConfiguration()
- {
- RecentItemDays = 14;
- }
- }
-}
diff --git a/MediaBrowser.Model/DTO/ApiBaseItem.cs b/MediaBrowser.Model/DTO/ApiBaseItem.cs
index d6b0f4a04..eca45c9f8 100644
--- a/MediaBrowser.Model/DTO/ApiBaseItem.cs
+++ b/MediaBrowser.Model/DTO/ApiBaseItem.cs
@@ -20,14 +20,14 @@ namespace MediaBrowser.Model.DTO
/// <summary>
/// This is the full return object when requesting an Item
/// </summary>
- public class BaseItemWrapper<T>
- where T : BaseItem
+ public class BaseItemContainer<TItemType>
+ where TItemType : BaseItem
{
- public T Item { get; set; }
+ public TItemType Item { get; set; }
public UserItemData UserItemData { get; set; }
- public IEnumerable<BaseItemWrapper<T>> Children { get; set; }
+ public IEnumerable<BaseItemContainer<TItemType>> Children { get; set; }
public bool IsFolder { get; set; }
@@ -45,7 +45,8 @@ namespace MediaBrowser.Model.DTO
return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
}
- public IEnumerable<PersonInfo> People { get; set; }
+ public IEnumerable<BaseItemPerson> People { get; set; }
+ public IEnumerable<BaseItemStudio> Studios { get; set; }
/// <summary>
/// If the item does not have a logo, this will hold the Id of the Parent that has one.
@@ -60,7 +61,7 @@ namespace MediaBrowser.Model.DTO
/// <summary>
/// This is strictly for convenience so the UI's don't have to use the verbose generic syntax of BaseItemWrapper<ApiBaseItem>
/// </summary>
- public class ApiBaseItemWrapper : BaseItemWrapper<ApiBaseItem>
+ public class ApiBaseItemContainer : BaseItemContainer<ApiBaseItem>
{
}
}
diff --git a/MediaBrowser.Model/DTO/CategoryInfo.cs b/MediaBrowser.Model/DTO/CategoryInfo.cs
deleted file mode 100644
index e6b2aeafb..000000000
--- a/MediaBrowser.Model/DTO/CategoryInfo.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-namespace MediaBrowser.Model.DTO
-{
- /// <summary>
- /// This is a stub class used by the api to get IBN types along with their item counts
- /// </summary>
- public class CategoryInfo<T>
- {
- /// <summary>
- /// The actual genre, year, studio, etc
- /// </summary>
- public T Item { get; set; }
-
- /// <summary>
- /// The number of items that have the genre, year, studio, etc
- /// </summary>
- public int ItemCount { get; set; }
- }
-}
diff --git a/MediaBrowser.Model/DTO/IBNItem.cs b/MediaBrowser.Model/DTO/IBNItem.cs
new file mode 100644
index 000000000..8a0620767
--- /dev/null
+++ b/MediaBrowser.Model/DTO/IBNItem.cs
@@ -0,0 +1,38 @@
+using MediaBrowser.Model.Entities;
+
+namespace MediaBrowser.Model.DTO
+{
+ /// <summary>
+ /// This is a stub class used by the api to get IBN types along with their item counts
+ /// </summary>
+ public class IBNItem<T>
+ {
+ /// <summary>
+ /// The actual genre, year, studio, etc
+ /// </summary>
+ public T Item { get; set; }
+
+ /// <summary>
+ /// The number of items that have the genre, year, studio, etc
+ /// </summary>
+ public int BaseItemCount { get; set; }
+ }
+
+ /// <summary>
+ /// This is used by BaseItemContainer
+ /// </summary>
+ public class BaseItemPerson
+ {
+ public PersonInfo PersonInfo { get; set; }
+ public string PrimaryImagePath { get; set; }
+ }
+
+ /// <summary>
+ /// This is used by BaseItemContainer
+ /// </summary>
+ public class BaseItemStudio
+ {
+ public string Name { get; set; }
+ public string PrimaryImagePath { get; set; }
+ }
+}
diff --git a/MediaBrowser.Model/Entities/Person.cs b/MediaBrowser.Model/Entities/Person.cs
index 690a2de85..e85f8a905 100644
--- a/MediaBrowser.Model/Entities/Person.cs
+++ b/MediaBrowser.Model/Entities/Person.cs
@@ -6,7 +6,6 @@ namespace MediaBrowser.Model.Entities
/// </summary>
public class Person : BaseEntity
{
- public PersonType PersonType { get; set; }
}
/// <summary>
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index dd9034ed5..14c7843ed 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -32,12 +32,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Compile Include="Configuration\UserConfiguration.cs" />
<Compile Include="DTO\ApiBaseItem.cs" />
<Compile Include="Entities\Audio.cs" />
<Compile Include="Entities\BaseEntity.cs" />
<Compile Include="Entities\BaseItem.cs" />
- <Compile Include="DTO\CategoryInfo.cs" />
+ <Compile Include="DTO\IBNItem.cs" />
<Compile Include="Entities\Folder.cs" />
<Compile Include="Entities\Genre.cs" />
<Compile Include="Entities\ImageType.cs" />
diff --git a/MediaBrowser.Model/Users/User.cs b/MediaBrowser.Model/Users/User.cs
index 63698dc85..85776fb8b 100644
--- a/MediaBrowser.Model/Users/User.cs
+++ b/MediaBrowser.Model/Users/User.cs
@@ -10,5 +10,12 @@ namespace MediaBrowser.Model.Users
private Dictionary<Guid, UserItemData> _ItemData = new Dictionary<Guid, UserItemData>();
public Dictionary<Guid, UserItemData> ItemData { get { return _ItemData; } set { _ItemData = value; } }
+
+ public int RecentItemDays { get; set; }
+
+ public User()
+ {
+ RecentItemDays = 14;
+ }
}
}