The Free Software Media System - Server Backend & API
Consolidated handlers that return lists of items. Renamed ApiBaseItemWrapper to ApiBaseItemContainer. Added Person and Studio DTO's to BaseItemWrapper
LukePulverenti Luke Pulverenti luke pulverenti5c6ec34a9cff
diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.csindex e4a7f71bf5..25a7ff9ec1 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.Apiwrapper.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.csindex c3292d3633..902871fa11 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.csdeleted file mode 100644index 2bee275a45..0000000000--- 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.csindex efb67db54e..3df8e914fb 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.csindex 6e08561b23..b3d85687fe 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.HttpHandlersreturn 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.csdeleted file mode 100644index 16bb561967..0000000000--- 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.csdeleted file mode 100644index 624abc7620..0000000000--- 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.csdeleted file mode 100644index 30120d5248..0000000000--- 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.csdeleted file mode 100644index d5d4df4446..0000000000--- 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.csdeleted file mode 100644index f36c9c9975..0000000000--- 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.csindex b1be2cad2a..b33988b3ec 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.csdeleted file mode 100644index 12e80f3060..0000000000--- 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.csindex cc34748805..8a58a2a19d 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.csprojindex e6a1816f6d..4b6b6aa1a2 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.csindex 6bfdd5134a..659763c5fc 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.csindex 7818dbdf8b..af79513e09 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.ApiInteractionusing (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.ApiInteractionusing (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.csindex 56f3a854fa..88d1012b18 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.csindex ef9a07814b..375b11a593 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.Controllerif (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.Controllerif (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.Controllerif (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.csdeleted file mode 100644index 5616f6dd60..0000000000--- 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.csindex d6b0f4a047..eca45c9f8b 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.DTOreturn 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.csdeleted file mode 100644index e6b2aeafb0..0000000000--- 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.csnew file mode 100644index 0000000000..8a0620767f--- /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.csindex 690a2de857..e85f8a9050 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.csprojindex dd9034ed56..14c7843edf 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.csindex 63698dc857..85776fb8b8 100644--- a/MediaBrowser.Model/Users/User.cs+++ b/MediaBrowser.Model/Users/User.cs@@ -10,5 +10,12 @@ namespace MediaBrowser.Model.Usersprivate 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;+ }}}