The Free Software Media System - Server Backend & API
All calls to get items now require passing in a userId. Made the model project portable. Also filled in more api calls.
LukePulverenti Luke Pulverenti luke pulverenti6fbd5cf46407
diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.csindex b0cc54feea..2687ce81a0 100644--- a/MediaBrowser.Api/ApiService.cs+++ b/MediaBrowser.Api/ApiService.cs@@ -9,52 +9,91 @@ namespace MediaBrowser.Api{public static BaseItem GetItemById(string id){- if (string.IsNullOrEmpty(id))- {- return Kernel.Instance.RootFolder;- }+ Guid guid = string.IsNullOrEmpty(id) ? Guid.Empty : new Guid(id);- return GetItemById(new Guid(id));+ return Kernel.Instance.GetItemById(guid);}- public static BaseItem GetItemById(Guid id)+ public static IEnumerable<CategoryInfo> GetAllStudios(Folder parent, Guid userId){- if (id == Guid.Empty)+ Dictionary<string, int> data = new Dictionary<string, int>();++ IEnumerable<BaseItem> allItems = Kernel.Instance.GetParentalAllowedRecursiveChildren(parent, userId);++ foreach (var item in allItems){- return Kernel.Instance.RootFolder;+ if (item.Studios == null)+ {+ continue;+ }++ foreach (string val in item.Studios)+ {+ if (!data.ContainsKey(val))+ {+ data.Add(val, 1);+ }+ else+ {+ data[val]++;+ }+ }}- return Kernel.Instance.RootFolder.FindById(id);- }+ List<CategoryInfo> list = new List<CategoryInfo>();- public static Person GetPersonByName(string name)- {- return null;- }+ foreach (string key in data.Keys)+ {+ list.Add(new CategoryInfo()+ {+ Name = key,+ ItemCount = data[key]- public static IEnumerable<BaseItem> GetItemsWithGenre(Folder parent, string genre)- {- return new BaseItem[] { };+ });+ }++ return list;}- public static IEnumerable<string> GetAllGenres(Folder parent)+ public static IEnumerable<CategoryInfo> GetAllGenres(Folder parent, Guid userId){- return new string[] { };- }+ Dictionary<string, int> data = new Dictionary<string, int>();- public static IEnumerable<BaseItem> GetRecentlyAddedItems(Folder parent)- {- return new BaseItem[] { };- }+ IEnumerable<BaseItem> allItems = Kernel.Instance.GetParentalAllowedRecursiveChildren(parent, userId);- public static IEnumerable<BaseItem> GetRecentlyAddedUnplayedItems(Folder parent)- {- return new BaseItem[] { };- }+ foreach (var item in allItems)+ {+ if (item.Genres == null)+ {+ continue;+ }- public static IEnumerable<BaseItem> GetInProgressItems(Folder parent)- {- return new BaseItem[] { };+ foreach (string val in item.Genres)+ {+ if (!data.ContainsKey(val))+ {+ data.Add(val, 1);+ }+ else+ {+ data[val]++;+ }+ }+ }++ List<CategoryInfo> list = new List<CategoryInfo>();++ foreach (string key in data.Keys)+ {+ list.Add(new CategoryInfo()+ {+ Name = key,+ ItemCount = data[key]++ });+ }++ return list;}}}diff --git a/MediaBrowser.Api/HttpHandlers/GenreHandler.cs b/MediaBrowser.Api/HttpHandlers/GenreHandler.csindex 27731e39f0..f43e3e1b02 100644--- a/MediaBrowser.Api/HttpHandlers/GenreHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/GenreHandler.cs@@ -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);}}}diff --git a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs b/MediaBrowser.Api/HttpHandlers/GenresHandler.csindex 23755a7a48..794b746cd4 100644--- a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs@@ -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.HttpHandlersget{Folder parent = ApiService.GetItemById(QueryString["id"]) as Folder;+ Guid userId = Guid.Parse(QueryString["userid"]);- return ApiService.GetAllGenres(parent);+ return ApiService.GetAllGenres(parent, userId);}}}diff --git a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs b/MediaBrowser.Api/HttpHandlers/ImageHandler.csindex 12b3d6e572..ed6dcc3a9d 100644--- a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ImageHandler.cs@@ -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.HttpHandlersif (!string.IsNullOrEmpty(personName)){- item = ApiService.GetPersonByName(personName);+ item = Kernel.Instance.ItemController.GetPerson(personName);}else{diff --git a/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs b/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.csindex 148964f89a..e13cee866c 100644--- a/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/InProgressItemsHandler.cs@@ -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);}}}diff --git a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemHandler.csindex 7b4b02b630..dd508d1037 100644--- a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs@@ -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 ItemToSerializediff --git a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemListHandler.csindex 33b3f9e71e..ed6e895f38 100644--- a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs@@ -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"]);+ }+ }}}diff --git a/MediaBrowser.Api/HttpHandlers/PersonHandler.cs b/MediaBrowser.Api/HttpHandlers/PersonHandler.csindex 066ab4816d..6a9d376791 100644--- a/MediaBrowser.Api/HttpHandlers/PersonHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/PersonHandler.cs@@ -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"]);}}}diff --git a/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs b/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.csindex 46084e7f29..8d85eedf4e 100644--- a/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/RecentlyAddedItemsHandler.cs@@ -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.HttpHandlersif (QueryString["unplayed"] == "1"){- return ApiService.GetRecentlyAddedUnplayedItems(parent);+ return Kernel.Instance.GetRecentlyAddedUnplayedItems(parent, UserId);}- return ApiService.GetRecentlyAddedItems(parent);+ return Kernel.Instance.GetRecentlyAddedItems(parent, UserId);}}}diff --git a/MediaBrowser.Api/HttpHandlers/StudioHandler.cs b/MediaBrowser.Api/HttpHandlers/StudioHandler.csnew file mode 100644index 0000000000..9426d0b7c0--- /dev/null+++ b/MediaBrowser.Api/HttpHandlers/StudioHandler.cs@@ -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);+ }+ }+ }+}diff --git a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs b/MediaBrowser.Api/HttpHandlers/StudiosHandler.csnew file mode 100644index 0000000000..6b83b9e64f--- /dev/null+++ b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs@@ -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);+ }+ }+ }+}diff --git a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs b/MediaBrowser.Api/HttpHandlers/UsersHandler.csnew file mode 100644index 0000000000..aa8dac11e4--- /dev/null+++ b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs@@ -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;+ }+ }+ }+}diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csprojindex 18bc85ff21..f493da552a 100644--- a/MediaBrowser.Api/MediaBrowser.Api.csproj+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj@@ -53,8 +53,12 @@<Compile Include="HttpHandlers\ItemListHandler.cs" /><Compile Include="HttpHandlers\PersonHandler.cs" /><Compile Include="HttpHandlers\RecentlyAddedItemsHandler.cs" />+ <Compile Include="HttpHandlers\StudioHandler.cs" />+ <Compile Include="HttpHandlers\StudiosHandler.cs" />+ <Compile Include="HttpHandlers\UsersHandler.cs" /><Compile Include="ImageProcessor.cs" /><Compile Include="HttpHandlers\MediaHandler.cs" />+ <Compile Include="Model\BaseItemInfo.cs" /><Compile Include="Plugin.cs" /><Compile Include="Properties\AssemblyInfo.cs" /></ItemGroup>@@ -68,13 +72,14 @@<Name>MediaBrowser.Controller</Name></ProjectReference><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup><ItemGroup><None Include="packages.config" /></ItemGroup>+ <ItemGroup /><Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /><PropertyGroup><PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\ProgramData\Plugins\$(ProjectName)\" /y</PostBuildEvent>diff --git a/MediaBrowser.Api/Model/BaseItemInfo.cs b/MediaBrowser.Api/Model/BaseItemInfo.csnew file mode 100644index 0000000000..646c273905--- /dev/null+++ b/MediaBrowser.Api/Model/BaseItemInfo.cs@@ -0,0 +1,15 @@+using System.Collections.Generic;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Users;++namespace MediaBrowser.Api.Model+{+ public class BaseItemInfo+ {+ public BaseItem Item { get; set; }++ public UserItemData UserItemData { get; set; }++ public IEnumerable<BaseItem> Children { get; set; }+ }+}diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.csindex 28b45b996b..91bd906c8b 100644--- a/MediaBrowser.Api/Plugin.cs+++ b/MediaBrowser.Api/Plugin.cs@@ -1,5 +1,4 @@using System;-using System.Collections.Generic;using System.Reactive.Linq;using MediaBrowser.Api.HttpHandlers;using MediaBrowser.Common.Plugins;@@ -13,6 +12,8 @@ namespace MediaBrowser.Api{var httpServer = Kernel.Instance.HttpServer;+ httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/users", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new UsersHandler(ctx)));+httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/media", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new MediaHandler(ctx)));httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/item", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new ItemHandler(ctx)));@@ -23,6 +24,10 @@ namespace MediaBrowser.ApihttpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/genres", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new GenresHandler(ctx)));+ httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/studio", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new StudioHandler(ctx)));++ httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/studios", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new StudiosHandler(ctx)));+httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/recentlyaddeditems", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new RecentlyAddedItemsHandler(ctx)));httpServer.Where(ctx => ctx.LocalPath.EndsWith("/api/inprogressitems", StringComparison.OrdinalIgnoreCase)).Subscribe(ctx => ctx.Respond(new InProgressItemsHandler(ctx)));diff --git a/MediaBrowser.Common/ApiInteraction/ApiController.cs b/MediaBrowser.Common/ApiInteraction/ApiController.csnew file mode 100644index 0000000000..f237573550--- /dev/null+++ b/MediaBrowser.Common/ApiInteraction/ApiController.cs@@ -0,0 +1,113 @@+using System;+using System.Collections.Generic;+using System.IO;+using System.IO.Compression;+using System.Net;+using System.Threading.Tasks;+using MediaBrowser.Common.Json;+using MediaBrowser.Model.Users;+using MediaBrowser.Model.Entities;++namespace MediaBrowser.Common.ApiInteraction+{+ public class ApiController+ {+ public string ApiUrl { get; set; }++ private WebClient WebClient { get; set; }++ public ApiController()+ {+ WebClient = new WebClient();+ }++ public async Task<DictionaryBaseItem> GetRootItem(Guid userId)+ {+ string url = ApiUrl + "/item?userId=" + userId.ToString();++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return DictionaryBaseItem.FromApiOutput(gzipStream);+ }+ }++ public async Task<DictionaryBaseItem> GetItem(Guid id, Guid userId)+ {+ string url = ApiUrl + "/item?userId=" + userId.ToString();++ if (id != Guid.Empty)+ {+ url += "&id=" + id.ToString();+ }++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return DictionaryBaseItem.FromApiOutput(gzipStream);+ }+ }++ public async Task<IEnumerable<User>> GetAllUsers()+ {+ string url = ApiUrl + "/users";++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return JsonSerializer.DeserializeFromStream<IEnumerable<User>>(gzipStream);+ }+ }++ public async Task<IEnumerable<CategoryInfo>> GetAllGenres(Guid userId)+ {+ string url = ApiUrl + "/genres?userId=" + userId.ToString();++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return JsonSerializer.DeserializeFromStream<IEnumerable<CategoryInfo>>(gzipStream);+ }+ }++ public async Task<CategoryInfo> GetGenre(string name, Guid userId)+ {+ string url = ApiUrl + "/genre?userId=" + userId.ToString() + "&name=" + name;++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return JsonSerializer.DeserializeFromStream<CategoryInfo>(gzipStream);+ }+ }++ public async Task<IEnumerable<CategoryInfo>> GetAllStudios(Guid userId)+ {+ string url = ApiUrl + "/studios?userId=" + userId.ToString();++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return JsonSerializer.DeserializeFromStream<IEnumerable<CategoryInfo>>(gzipStream);+ }+ }++ public async Task<CategoryInfo> GetStudio(string name, Guid userId)+ {+ string url = ApiUrl + "/studio?userId=" + userId.ToString() + "&name=" + name;++ Stream stream = await WebClient.OpenReadTaskAsync(url);++ using (GZipStream gzipStream = new GZipStream(stream, CompressionMode.Decompress, false))+ {+ return JsonSerializer.DeserializeFromStream<CategoryInfo>(gzipStream);+ }+ }+ }+}diff --git a/MediaBrowser.Common/ApiInteraction/DictionaryBaseItem.cs b/MediaBrowser.Common/ApiInteraction/DictionaryBaseItem.csnew file mode 100644index 0000000000..2bd6f1bcd5--- /dev/null+++ b/MediaBrowser.Common/ApiInteraction/DictionaryBaseItem.cs@@ -0,0 +1,412 @@+using System;+using System.Collections.Generic;+using System.IO;+using MediaBrowser.Common.Json;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Users;+using System.Linq;++namespace MediaBrowser.Common.ApiInteraction+{+ public class DictionaryBaseItem : BaseItem+ {+ private Dictionary<string, object> Dictionary { get; set; }++ public UserItemData UserItemData { get; set; }+ public IEnumerable<DictionaryBaseItem> Children { get; set; }++ public DictionaryBaseItem(Dictionary<string, object> dictionary)+ {+ Dictionary = dictionary;+ }++ public override string Name+ {+ get+ {+ return GetString("Name");+ }+ set+ {+ SetValue("Name", value);+ }+ }++ public override string ArtImagePath+ {+ get+ {+ return GetString("ArtImagePath");+ }+ set+ {+ SetValue("ArtImagePath", value);+ }+ }++ public override string AspectRatio+ {+ get+ {+ return GetString("AspectRatio");+ }+ set+ {+ SetValue("AspectRatio", value);+ }+ }++ public override string BannerImagePath+ {+ get+ {+ return GetString("BannerImagePath");+ }+ set+ {+ SetValue("BannerImagePath", value);+ }+ }++ public override string CustomPin+ {+ get+ {+ return GetString("CustomPin");+ }+ set+ {+ SetValue("CustomPin", value);+ }+ }++ public override string CustomRating+ {+ get+ {+ return GetString("CustomRating");+ }+ set+ {+ SetValue("CustomRating", value);+ }+ }++ public override string DisplayMediaType+ {+ get+ {+ return GetString("DisplayMediaType");+ }+ set+ {+ SetValue("DisplayMediaType", value);+ }+ }++ public override string LogoImagePath+ {+ get+ {+ return GetString("LogoImagePath");+ }+ set+ {+ SetValue("LogoImagePath", value);+ }+ }++ public override string OfficialRating+ {+ get+ {+ return GetString("OfficialRating");+ }+ set+ {+ SetValue("OfficialRating", value);+ }+ }++ public override string Overview+ {+ get+ {+ return GetString("Overview");+ }+ set+ {+ SetValue("Overview", value);+ }+ }++ public override string Path+ {+ get+ {+ return GetString("Path");+ }+ set+ {+ SetValue("Path", value);+ }+ }++ public override string PrimaryImagePath+ {+ get+ {+ return GetString("PrimaryImagePath");+ }+ set+ {+ SetValue("PrimaryImagePath", value);+ }+ }++ public override string SortName+ {+ get+ {+ return GetString("SortName");+ }+ set+ {+ SetValue("SortName", value);+ }+ }++ public override string Tagline+ {+ get+ {+ return GetString("Tagline");+ }+ set+ {+ SetValue("Tagline", value);+ }+ }++ public override string TrailerUrl+ {+ get+ {+ return GetString("TrailerUrl");+ }+ set+ {+ SetValue("TrailerUrl", value);+ }+ }++ public override DateTime DateCreated+ {+ get+ {+ return GetDateTime("DateCreated");+ }+ set+ {+ SetValue("DateCreated", value);+ }+ }++ public override DateTime DateModified+ {+ get+ {+ return GetDateTime("DateModified");+ }+ set+ {+ SetValue("DateModified", value);+ }+ }++ public override float? UserRating+ {+ get+ {+ return GetNullableFloat("UserRating");+ }+ set+ {+ SetValue("UserRating", value);+ }+ }++ public override string ThumbnailImagePath+ {+ get+ {+ return GetString("ThumbnailImagePath");+ }+ set+ {+ SetValue("ThumbnailImagePath", value);+ }+ }++ public override int? ProductionYear+ {+ get+ {+ return GetNullableInt("ProductionYear");+ }+ set+ {+ SetValue("ProductionYear", value);+ }+ }++ public override TimeSpan? RunTime+ {+ get+ {+ return GetNullableTimeSpan("RunTime");+ }+ set+ {+ SetValue("RunTime", value);+ }+ }++ public bool IsFolder+ {+ get+ {+ return GetBool("IsFolder");+ }+ }++ public override Guid Id+ {+ get+ {+ return GetGuid("Id");+ }+ set+ {+ SetValue("Id", value);+ }+ }++ public TimeSpan? GetNullableTimeSpan(string name)+ {+ string val = Dictionary[name] as string;++ if (string.IsNullOrEmpty(val))+ {+ return null;+ }++ return TimeSpan.Parse(val);+ }++ public int? GetNullableInt(string name)+ {+ string val = Dictionary[name] as string;++ if (string.IsNullOrEmpty(val))+ {+ return null;+ }++ return int.Parse(val);+ }++ public float? GetNullableFloat(string name)+ {+ string val = Dictionary[name] as string;++ if (string.IsNullOrEmpty(val))+ {+ return null;+ }++ return float.Parse(val);+ }++ public DateTime? GetNullableDateTime(string name)+ {+ string val = Dictionary[name] as string;++ if (string.IsNullOrEmpty(val))+ {+ return null;+ }++ return DateTime.Parse(val);+ }++ public DateTime GetDateTime(string name)+ {+ DateTime? val = GetNullableDateTime(name);++ return val ?? DateTime.MinValue;+ }++ public bool? GetNullableBool(string name)+ {+ string val = Dictionary[name] as string;++ if (string.IsNullOrEmpty(val))+ {+ return null;+ }++ return val != "false";+ }++ public Guid GetGuid(string name)+ {+ string val = GetString(name);++ if (string.IsNullOrEmpty(val))+ {+ return Guid.Empty;+ }++ return Guid.Parse(val);+ }++ public bool GetBool(string name)+ {+ bool? val = GetNullableBool(name);++ return val ?? false;+ }++ public string GetString(string name)+ {+ return Dictionary[name] as string;+ }++ private void SetValue<T>(string name, T value)+ {+ Dictionary[name] = value;+ }++ public static DictionaryBaseItem FromApiOutput(Stream stream)+ {+ Dictionary<string, object> data = JsonSerializer.DeserializeFromStream<Dictionary<string, object>>(stream);++ string baseItem = data["Item"] as string;++ DictionaryBaseItem item = new DictionaryBaseItem(JsonSerializer.DeserializeFromString<Dictionary<string, object>>(baseItem));++ if (data.ContainsKey("UserItemData"))+ {+ item.UserItemData = JsonSerializer.DeserializeFromString<UserItemData>(data["UserItemData"].ToString());+ }++ if (data.ContainsKey("Children"))+ {+ item.Children = JsonSerializer.DeserializeFromString<IEnumerable<Dictionary<string, object>>>(data["Children"].ToString()).Select(c => new DictionaryBaseItem(c));+ }++ return item;+ }+ }+}diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csprojindex 8ee14d3a98..f822b1a2bd 100644--- a/MediaBrowser.Common/MediaBrowser.Common.csproj+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj@@ -45,9 +45,10 @@<Reference Include="System.Xml" /></ItemGroup><ItemGroup>+ <Compile Include="ApiInteraction\ApiController.cs" /><Compile Include="Events\GenericItemEventArgs.cs" /><Compile Include="Json\JsonSerializer.cs" />- <Compile Include="Model\DictionaryBaseItem.cs" />+ <Compile Include="ApiInteraction\DictionaryBaseItem.cs" /><Compile Include="Net\CollectionExtensions.cs" /><Compile Include="Net\Handlers\BaseEmbeddedResourceHandler.cs" /><Compile Include="Net\Handlers\JsonHandler.cs" />@@ -70,7 +71,7 @@</ItemGroup><ItemGroup><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup>diff --git a/MediaBrowser.Common/Model/DictionaryBaseItem.cs b/MediaBrowser.Common/Model/DictionaryBaseItem.csdeleted file mode 100644index 8bdcf1460b..0000000000--- a/MediaBrowser.Common/Model/DictionaryBaseItem.cs+++ /dev/null@@ -1,227 +0,0 @@-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;-using MediaBrowser.Model.Entities;-using System.IO;-using MediaBrowser.Common.Json;--namespace MediaBrowser.Common.Model-{- public class DictionaryBaseItem : BaseItem- {- private Dictionary<string, object> Dictionary { get; set; }-- public DictionaryBaseItem(Dictionary<string, object> dictionary)- {- Dictionary = dictionary;- }-- public override string Name- {- get- {- return GetString("Name");- }- set- {- SetValue("Name", value);- }- }-- public override string ArtImagePath- {- get- {- return GetString("ArtImagePath");- }- set- {- SetValue("ArtImagePath", value);- }- }-- public override string AspectRatio- {- get- {- return GetString("AspectRatio");- }- set- {- SetValue("AspectRatio", value);- }- }-- public override string BannerImagePath- {- get- {- return GetString("BannerImagePath");- }- set- {- SetValue("BannerImagePath", value);- }- }-- public override string CustomPin- {- get- {- return GetString("CustomPin");- }- set- {- SetValue("CustomPin", value);- }- }-- public override string CustomRating- {- get- {- return GetString("CustomRating");- }- set- {- SetValue("CustomRating", value);- }- }-- public override string DisplayMediaType- {- get- {- return GetString("DisplayMediaType");- }- set- {- SetValue("DisplayMediaType", value);- }- }-- public override string LogoImagePath- {- get- {- return GetString("LogoImagePath");- }- set- {- SetValue("LogoImagePath", value);- }- }-- public override string OfficialRating- {- get- {- return GetString("OfficialRating");- }- set- {- SetValue("OfficialRating", value);- }- }-- public override string Overview- {- get- {- return GetString("Overview");- }- set- {- SetValue("Overview", value);- }- }-- public override string Path- {- get- {- return GetString("Path");- }- set- {- SetValue("Path", value);- }- }-- public override string PrimaryImagePath- {- get- {- return GetString("PrimaryImagePath");- }- set- {- SetValue("PrimaryImagePath", value);- }- }-- public override string SortName- {- get- {- return GetString("SortName");- }- set- {- SetValue("SortName", value);- }- }-- public override string Tagline- {- get- {- return GetString("Tagline");- }- set- {- SetValue("Tagline", value);- }- }-- public override string TrailerUrl- {- get- {- return GetString("TrailerUrl");- }- set- {- SetValue("TrailerUrl", value);- }- }-- private string GetString(string name)- {- return Dictionary[name] as string;- }-- private void SetValue<T>(string name, T value)- {- Dictionary[name] = value;- }-- public static DictionaryBaseItem FromApiOutput(Stream stream)- {- Dictionary<string,object> data = JsonSerializer.DeserializeFromStream<Dictionary<string, object>>(stream);-- if (data.ContainsKey("BaseItem"))- {- string baseItem = data["BaseItem"] as string;-- data = JsonSerializer.DeserializeFromString<Dictionary<string, object>>(baseItem);-- return new DictionaryBaseItem(data);- }-- return new DictionaryBaseItem(data);- }- }-}diff --git a/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj b/MediaBrowser.Configuration/MediaBrowser.Configuration.csprojindex 356aa502f2..b94672537b 100644--- a/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj+++ b/MediaBrowser.Configuration/MediaBrowser.Configuration.csproj@@ -55,10 +55,6 @@<Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project><Name>MediaBrowser.Controller</Name></ProjectReference>- <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>- <Name>MediaBrowser.Model</Name>- </ProjectReference></ItemGroup><ItemGroup><None Include="packages.config" />diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.csindex 3db0cca8f0..3f6e7bbb0e 100644--- a/MediaBrowser.Controller/Kernel.cs+++ b/MediaBrowser.Controller/Kernel.cs@@ -84,7 +84,6 @@ namespace MediaBrowser.Controller// Get users from users folder// Load root media folderParallel.Invoke(ReloadUsers, ReloadRoot);- var b = true;}private void ReloadConfiguration()@@ -234,5 +233,131 @@ namespace MediaBrowser.Controlleritem.Parent.Children = children.ToArray();}}++ /// <summary>+ /// Finds a library item by Id+ /// </summary>+ public BaseItem GetItemById(Guid id)+ {+ if (id == Guid.Empty)+ {+ return RootFolder;+ }++ return RootFolder.FindById(id);+ }++ /// <summary>+ /// Determines if an item is allowed for a given user+ /// </summary>+ public bool IsParentalAllowed(BaseItem item, Guid userId)+ {+ // not yet implemented+ return true;+ }++ /// <summary>+ /// Gets allowed children of an item+ /// </summary>+ public IEnumerable<BaseItem> GetParentalAllowedChildren(Folder folder, Guid userId)+ {+ return folder.Children.ToList().Where(i => IsParentalAllowed(i, userId));+ }++ /// <summary>+ /// Gets allowed recursive children of an item+ /// </summary>+ public IEnumerable<BaseItem> GetParentalAllowedRecursiveChildren(Folder folder, Guid userId)+ {+ foreach (var item in GetParentalAllowedChildren(folder, userId))+ {+ yield return item;++ var subFolder = item as Folder;++ if (subFolder != null)+ {+ foreach (var subitem in GetParentalAllowedRecursiveChildren(subFolder, userId))+ {+ yield return subitem;+ }+ }+ }+ }++ /// <summary>+ /// Gets user data for an item, if there is any+ /// </summary>+ public UserItemData GetUserItemData(Guid userId, Guid itemId)+ {+ User user = Users.First(u => u.Id == userId);++ if (user.ItemData.ContainsKey(itemId))+ {+ return user.ItemData[itemId];+ }++ return null;+ }++ /// <summary>+ /// Gets all recently added items (recursive) within a folder, based on configuration and parental settings+ /// </summary>+ public IEnumerable<BaseItem> GetRecentlyAddedItems(Folder parent, Guid userId)+ {+ DateTime now = DateTime.Now;++ return GetParentalAllowedRecursiveChildren(parent, userId).Where(i => (now - i.DateCreated).TotalDays < Configuration.RecentItemDays);+ }++ /// <summary>+ /// Gets all recently added unplayed items (recursive) within a folder, based on configuration and parental settings+ /// </summary>+ public IEnumerable<BaseItem> GetRecentlyAddedUnplayedItems(Folder parent, Guid userId)+ {+ return GetRecentlyAddedItems(parent, userId).Where(i =>+ {+ var userdata = GetUserItemData(userId, i.Id);++ return userdata == null || userdata.PlayCount == 0;+ });+ }++ /// <summary>+ /// Gets all in-progress items (recursive) within a folder+ /// </summary>+ public IEnumerable<BaseItem> GetInProgressItems(Folder parent, Guid userId)+ {+ return GetParentalAllowedRecursiveChildren(parent, userId).Where(i =>+ {+ var userdata = GetUserItemData(userId, i.Id);++ return userdata != null && userdata.PlaybackPosition.Ticks > 0;+ });+ }++ /// <summary>+ /// Finds all recursive items within a top-level parent that contain the given studio and are allowed for the current user+ /// </summary>+ public IEnumerable<BaseItem> GetItemsWithStudio(Folder parent, string studio, Guid userId)+ {+ return GetParentalAllowedRecursiveChildren(parent, userId).Where(f => f.Studios != null && f.Studios.Any(s => s.Equals(studio, StringComparison.OrdinalIgnoreCase)));+ }++ /// <summary>+ /// Finds all recursive items within a top-level parent that contain the given genre and are allowed for the current user+ /// </summary>+ public IEnumerable<BaseItem> GetItemsWithGenre(Folder parent, string genre, Guid userId)+ {+ return GetParentalAllowedRecursiveChildren(parent, userId).Where(f => f.Genres != null && f.Genres.Any(s => s.Equals(genre, StringComparison.OrdinalIgnoreCase)));+ }++ /// <summary>+ /// Finds all recursive items within a top-level parent that contain the given person and are allowed for the current user+ /// </summary>+ public IEnumerable<BaseItem> GetItemsWithPerson(Folder parent, string personName, Guid userId)+ {+ return GetParentalAllowedRecursiveChildren(parent, userId).Where(f => f.People != null && f.People.Any(s => s.Name.Equals(personName, StringComparison.OrdinalIgnoreCase)));+ }}}diff --git a/MediaBrowser.Controller/Library/ItemController.cs b/MediaBrowser.Controller/Library/ItemController.csindex f0be2baf9b..b872e8dbae 100644--- a/MediaBrowser.Controller/Library/ItemController.cs+++ b/MediaBrowser.Controller/Library/ItemController.cs@@ -310,5 +310,23 @@ namespace MediaBrowser.Controller.Libraryreturn returnFiles;}++ public Person GetPerson(string name)+ {+ // not yet implemented+ return null;+ }++ public Studio GetStudio(string name)+ {+ // not yet implemented+ return null;+ }++ public Year GetYear(int value)+ {+ // not yet implemented+ return null;+ }}}diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csprojindex c89a32c268..719d279eeb 100644--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj@@ -63,7 +63,7 @@<Name>MediaBrowser.Common</Name></ProjectReference><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup>diff --git a/MediaBrowser.HtmlBrowser/MediaBrowser.HtmlBrowser.csproj b/MediaBrowser.HtmlBrowser/MediaBrowser.HtmlBrowser.csprojindex d01ca1b1dc..219ec35c53 100644--- a/MediaBrowser.HtmlBrowser/MediaBrowser.HtmlBrowser.csproj+++ b/MediaBrowser.HtmlBrowser/MediaBrowser.HtmlBrowser.csproj@@ -56,7 +56,7 @@<Name>MediaBrowser.Controller</Name></ProjectReference><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup>diff --git a/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj b/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csprojindex 7503443318..3b88a5b56b 100644--- a/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj+++ b/MediaBrowser.InternetProviders/MediaBrowser.InternetProviders.csproj@@ -52,10 +52,6 @@<Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project><Name>MediaBrowser.Controller</Name></ProjectReference>- <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>- <Name>MediaBrowser.Model</Name>- </ProjectReference><ProjectReference Include="..\MediaBrowser.Movies\MediaBrowser.Movies.csproj"><Project>{92b9f802-4415-438f-90e1-44602135ea41}</Project><Name>MediaBrowser.Movies</Name>diff --git a/MediaBrowser.Model/Configuration/Configuration.cs b/MediaBrowser.Model/Configuration/Configuration.csindex 63ed22fc5a..e7dc4b8438 100644--- a/MediaBrowser.Model/Configuration/Configuration.cs+++ b/MediaBrowser.Model/Configuration/Configuration.cs@@ -6,11 +6,13 @@ namespace MediaBrowser.Model.Configuration{public string ImagesByNamePath { get; set; }public int HttpServerPortNumber { get; set; }+ public int RecentItemDays { get; set; }public LogSeverity LogSeverity { get; set; }public Configuration(){HttpServerPortNumber = 8096;+ RecentItemDays = 14;LogSeverity = LogSeverity.Info;}}diff --git a/MediaBrowser.Model/Entities/Audio.cs b/MediaBrowser.Model/Entities/Audio.csindex b243411adb..bfd739b5a7 100644--- a/MediaBrowser.Model/Entities/Audio.cs+++ b/MediaBrowser.Model/Entities/Audio.cs@@ -1,9 +1,4 @@-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;-+namespace MediaBrowser.Model.Entities{public class Audio : BaseItemdiff --git a/MediaBrowser.Model/Entities/BaseItem.cs b/MediaBrowser.Model/Entities/BaseItem.csindex a9c564a284..165328ac7b 100644--- a/MediaBrowser.Model/Entities/BaseItem.cs+++ b/MediaBrowser.Model/Entities/BaseItem.cs@@ -51,6 +51,7 @@ namespace MediaBrowser.Model.Entitiespublic virtual string AspectRatio { get; set; }public virtual int? ProductionYear { get; set; }+ [IgnoreDataMember]public virtual IEnumerable<Video> LocalTrailers { get; set; }public virtual string TrailerUrl { get; set; }@@ -60,17 +61,6 @@ namespace MediaBrowser.Model.Entitiesreturn Name;}- /// <summary>- /// This is strictly to enhance json output, until I can find a way to customize service stack to add this without having to use a property- /// </summary>- public virtual bool IsFolder- {- get- {- return false;- }- }-/// <summary>/// This is strictly to enhance json output, until I can find a way to customize service stack to add this without having to use a property/// </summary>diff --git a/MediaBrowser.Model/Entities/CategoryInfo.cs b/MediaBrowser.Model/Entities/CategoryInfo.csnew file mode 100644index 0000000000..adf8ac7d96--- /dev/null+++ b/MediaBrowser.Model/Entities/CategoryInfo.cs@@ -0,0 +1,21 @@++namespace MediaBrowser.Model.Entities+{+ /// <summary>+ /// This is a stub class used by the api to get IBN types in a compact format+ /// </summary>+ public class CategoryInfo+ {+ /// <summary>+ /// The name of the genre, year, studio, etc+ /// </summary>+ public string Name { get; set; }++ public string PrimaryImagePath { 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/Entities/Folder.cs b/MediaBrowser.Model/Entities/Folder.csindex 5ae47fea39..edcb981de9 100644--- a/MediaBrowser.Model/Entities/Folder.cs+++ b/MediaBrowser.Model/Entities/Folder.cs@@ -18,25 +18,12 @@ namespace MediaBrowser.Model.Entities}}- public override bool IsFolder- {- get- {- return true;- }- }-[IgnoreDataMember]public BaseItem[] Children { get; set; }[IgnoreDataMember]public IEnumerable<Folder> FolderChildren { get { return Children.OfType<Folder>(); } }- public Folder GetFolderByName(string name)- {- return FolderChildren.FirstOrDefault(f => System.IO.Path.GetFileName(f.Path).Equals(name, StringComparison.OrdinalIgnoreCase));- }-/// <summary>/// Finds an item by ID, recursively/// </summary>diff --git a/MediaBrowser.Model/Entities/Genre.cs b/MediaBrowser.Model/Entities/Genre.csnew file mode 100644index 0000000000..79dea52be3--- /dev/null+++ b/MediaBrowser.Model/Entities/Genre.cs@@ -0,0 +1,7 @@++namespace MediaBrowser.Model.Entities+{+ public class Genre : BaseItem+ {+ }+}diff --git a/MediaBrowser.Model/Entities/Person.cs b/MediaBrowser.Model/Entities/Person.csindex 521adb50cd..93f541a18e 100644--- a/MediaBrowser.Model/Entities/Person.cs+++ b/MediaBrowser.Model/Entities/Person.cs@@ -1,9 +1,4 @@-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;-+namespace MediaBrowser.Model.Entities{/// <summary>@@ -26,8 +21,9 @@ namespace MediaBrowser.Model.Entitiespublic enum PersonType{- Actor = 1,- Director = 2,- Writer = 3+ Actor,+ Director,+ Writer,+ Producer}}diff --git a/MediaBrowser.Model/Entities/PlaybackStatus.cs b/MediaBrowser.Model/Entities/PlaybackStatus.csdeleted file mode 100644index 042cfe0981..0000000000--- a/MediaBrowser.Model/Entities/PlaybackStatus.cs+++ /dev/null@@ -1,12 +0,0 @@-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;--namespace MediaBrowser.Model.Entities-{- public class PlaybackStatus- {- }-}diff --git a/MediaBrowser.Model/Entities/Studio.cs b/MediaBrowser.Model/Entities/Studio.csnew file mode 100644index 0000000000..da9582aeda--- /dev/null+++ b/MediaBrowser.Model/Entities/Studio.cs@@ -0,0 +1,7 @@++namespace MediaBrowser.Model.Entities+{+ public class Studio : BaseItem+ {+ }+}diff --git a/MediaBrowser.Model/Entities/Video.cs b/MediaBrowser.Model/Entities/Video.csindex 8b27f47c83..4d7b473bb0 100644--- a/MediaBrowser.Model/Entities/Video.cs+++ b/MediaBrowser.Model/Entities/Video.cs@@ -1,8 +1,4 @@-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;+using System.Collections.Generic;namespace MediaBrowser.Model.Entities{@@ -35,8 +31,8 @@ namespace MediaBrowser.Model.Entitiespublic enum VideoType{- VideoFile = 1,- DVD = 2,- BluRay = 3+ VideoFile,+ DVD,+ BluRay}}diff --git a/MediaBrowser.Model/Entities/Year.cs b/MediaBrowser.Model/Entities/Year.csnew file mode 100644index 0000000000..6c25f2ac5e--- /dev/null+++ b/MediaBrowser.Model/Entities/Year.cs@@ -0,0 +1,7 @@++namespace MediaBrowser.Model.Entities+{+ public class Year : BaseItem+ {+ }+}diff --git a/MediaBrowser.Model/Logging/LogSeverity.cs b/MediaBrowser.Model/Logging/LogSeverity.csindex 54187997fd..bac03acdd1 100644--- a/MediaBrowser.Model/Logging/LogSeverity.cs+++ b/MediaBrowser.Model/Logging/LogSeverity.cs@@ -1,8 +1,4 @@using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;namespace MediaBrowser.Model.Logging{diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex b0030dded4..431ec7fde7 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -4,13 +4,15 @@<PropertyGroup><Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration><Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>- <ProjectGuid>{9B1DDD79-5134-4DF3-ACE3-D1957A7350D8}</ProjectGuid>+ <ProjectGuid>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</ProjectGuid><OutputType>Library</OutputType><AppDesignerFolder>Properties</AppDesignerFolder><RootNamespace>MediaBrowser.Model</RootNamespace><AssemblyName>MediaBrowser.Model</AssemblyName>- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>+ <TargetFrameworkProfile>Profile4</TargetFrameworkProfile><FileAlignment>512</FileAlignment>+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids></PropertyGroup><PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "><DebugSymbols>true</DebugSymbols>@@ -30,29 +32,25 @@<WarningLevel>4</WarningLevel></PropertyGroup><ItemGroup>- <Reference Include="System" />- <Reference Include="System.Core" />- <Reference Include="System.Runtime.Serialization" />- <Reference Include="System.Xml.Linq" />- <Reference Include="System.Data.DataSetExtensions" />- <Reference Include="Microsoft.CSharp" />- <Reference Include="System.Data" />- <Reference Include="System.Xml" />+ <!-- A reference to the entire .NET Framework is automatically included --></ItemGroup><ItemGroup><Compile Include="Configuration\Configuration.cs" />- <Compile Include="Entities\Person.cs" /><Compile Include="Entities\Audio.cs" /><Compile Include="Entities\BaseItem.cs" />+ <Compile Include="Entities\CategoryInfo.cs" /><Compile Include="Entities\Folder.cs" />- <Compile Include="Entities\PlaybackStatus.cs" />+ <Compile Include="Entities\Genre.cs" />+ <Compile Include="Entities\Person.cs" />+ <Compile Include="Entities\Studio.cs" />+ <Compile Include="Entities\Video.cs" />+ <Compile Include="Entities\Year.cs" /><Compile Include="Logging\LogSeverity.cs" /><Compile Include="Properties\AssemblyInfo.cs" /><Compile Include="Users\User.cs" /><Compile Include="Users\UserItemData.cs" />- <Compile Include="Entities\Video.cs" /></ItemGroup>- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /><!-- To modify your build process, add your task inside one of the targets below and uncomment it.Other similar extension points exist, see Microsoft.Common.targets.<Target Name="BeforeBuild">diff --git a/MediaBrowser.Model/Properties/AssemblyInfo.cs b/MediaBrowser.Model/Properties/AssemblyInfo.csindex c5af59e202..6c64a5de60 100644--- a/MediaBrowser.Model/Properties/AssemblyInfo.cs+++ b/MediaBrowser.Model/Properties/AssemblyInfo.cs@@ -1,4 +1,5 @@-using System.Reflection;+using System.Resources;+using System.Reflection;using System.Runtime.CompilerServices;using System.Runtime.InteropServices;@@ -13,14 +14,7 @@ using System.Runtime.InteropServices;[assembly: AssemblyCopyright("Copyright © 2012")][assembly: AssemblyTrademark("")][assembly: AssemblyCulture("")]--// Setting ComVisible to false makes the types in this assembly not visible-// to COM components. If you need to access a type in this assembly from-// COM, set the ComVisible attribute to true on that type.-[assembly: ComVisible(false)]--// The following GUID is for the ID of the typelib if this project is exposed to COM-[assembly: Guid("4478b410-9582-4c22-b890-2a309708b9f1")]+[assembly: NeutralResourcesLanguage("en")]// Version information for an assembly consists of the following four values://diff --git a/MediaBrowser.Model/Users/User.cs b/MediaBrowser.Model/Users/User.csindex 19b65fce49..316e5b55c7 100644--- a/MediaBrowser.Model/Users/User.cs+++ b/MediaBrowser.Model/Users/User.cs@@ -1,8 +1,5 @@using System;using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;using MediaBrowser.Model.Entities;namespace MediaBrowser.Model.Users@@ -11,7 +8,6 @@ namespace MediaBrowser.Model.Users{public string Password { get; set; }public string MaxParentalRating { get; set; }- public bool HideBlockedContent { get; set; }private Dictionary<Guid, UserItemData> _ItemData = new Dictionary<Guid, UserItemData>();public Dictionary<Guid, UserItemData> ItemData { get { return _ItemData; } set { _ItemData = value; } }diff --git a/MediaBrowser.Model/Users/UserItemData.cs b/MediaBrowser.Model/Users/UserItemData.csindex ddb78555f3..9782711b09 100644--- a/MediaBrowser.Model/Users/UserItemData.cs+++ b/MediaBrowser.Model/Users/UserItemData.cs@@ -1,9 +1,5 @@-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;-using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Entities;+using System;namespace MediaBrowser.Model.Users{@@ -11,7 +7,9 @@ namespace MediaBrowser.Model.Users{public UserItemRating Rating { get; set; }- public PlaybackStatus PlaybackStatus { get; set; }+ public TimeSpan PlaybackPosition { get; set; }++ public int PlayCount { get; set; }}public enum UserItemRatingdiff --git a/MediaBrowser.Movies/Entities/Movie.cs b/MediaBrowser.Movies/Entities/Movie.csindex 95c86ccd69..2c44e7917e 100644--- a/MediaBrowser.Movies/Entities/Movie.cs+++ b/MediaBrowser.Movies/Entities/Movie.cs@@ -1,6 +1,6 @@-using System;-using System.Collections.Generic;+using System.Collections.Generic;using MediaBrowser.Model.Entities;+using System.Runtime.Serialization;namespace MediaBrowser.Movies.Entities{@@ -9,6 +9,7 @@ namespace MediaBrowser.Movies.Entitiespublic string TmdbId { get; set; }public string ImdbId { get; set; }+ [IgnoreDataMember]public IEnumerable<Video> SpecialFeatures { get; set; }}}diff --git a/MediaBrowser.Movies/MediaBrowser.Movies.csproj b/MediaBrowser.Movies/MediaBrowser.Movies.csprojindex 55816f78ec..88930f0f7b 100644--- a/MediaBrowser.Movies/MediaBrowser.Movies.csproj+++ b/MediaBrowser.Movies/MediaBrowser.Movies.csproj@@ -32,6 +32,7 @@<ItemGroup><Reference Include="System" /><Reference Include="System.Core" />+ <Reference Include="System.Runtime.Serialization" /><Reference Include="System.Xml.Linq" /><Reference Include="System.Data.DataSetExtensions" /><Reference Include="Microsoft.CSharp" />@@ -57,7 +58,7 @@<Name>MediaBrowser.Controller</Name></ProjectReference><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup>diff --git a/MediaBrowser.Program/MediaBrowser.Program.csproj b/MediaBrowser.Program/MediaBrowser.Program.csprojindex 8ad8182e66..adfc331b85 100644--- a/MediaBrowser.Program/MediaBrowser.Program.csproj+++ b/MediaBrowser.Program/MediaBrowser.Program.csproj@@ -58,7 +58,7 @@<Name>MediaBrowser.Controller</Name></ProjectReference><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup>diff --git a/MediaBrowser.TV/MediaBrowser.TV.csproj b/MediaBrowser.TV/MediaBrowser.TV.csprojindex 5f50e8bf08..a8128a0ebe 100644--- a/MediaBrowser.TV/MediaBrowser.TV.csproj+++ b/MediaBrowser.TV/MediaBrowser.TV.csproj@@ -62,7 +62,7 @@<Name>MediaBrowser.Controller</Name></ProjectReference><ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{9b1ddd79-5134-4df3-ace3-d1957a7350d8}</Project>+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project><Name>MediaBrowser.Model</Name></ProjectReference></ItemGroup>diff --git a/MediaBrowser.sln b/MediaBrowser.slnindex 361ecbcce6..6f94baf31d 100644--- a/MediaBrowser.sln+++ b/MediaBrowser.sln@@ -1,8 +1,6 @@Microsoft Visual Studio Solution File, Format Version 12.00# Visual Studio 2012-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Model", "MediaBrowser.Model\MediaBrowser.Model.csproj", "{9B1DDD79-5134-4DF3-ACE3-D1957A7350D8}"-EndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Controller", "MediaBrowser.Controller\MediaBrowser.Controller.csproj", "{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}"EndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Movies", "MediaBrowser.Movies\MediaBrowser.Movies.csproj", "{92B9F802-4415-438F-90E1-44602135EA41}"@@ -21,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.HtmlBrowser",EndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Common", "MediaBrowser.Common\MediaBrowser.Common.csproj", "{9142EEFA-7570-41E1-BFCC-468BB571AF2F}"EndProject+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Model", "MediaBrowser.Model\MediaBrowser.Model.csproj", "{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}"+EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolutionDebug|Any CPU = Debug|Any CPU@@ -47,6 +47,10 @@ Global{78AEA637-AF42-4F43-8E2B-0F2F0E2931F3}.Debug|Any CPU.Build.0 = Debug|Any CPU{78AEA637-AF42-4F43-8E2B-0F2F0E2931F3}.Release|Any CPU.ActiveCfg = Release|Any CPU{78AEA637-AF42-4F43-8E2B-0F2F0E2931F3}.Release|Any CPU.Build.0 = Release|Any CPU+ {7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU+ {7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.Build.0 = Debug|Any CPU+ {7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.ActiveCfg = Release|Any CPU+ {7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.Build.0 = Release|Any CPU{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Debug|Any CPU.Build.0 = Debug|Any CPU{9142EEFA-7570-41E1-BFCC-468BB571AF2F}.Release|Any CPU.ActiveCfg = Release|Any CPU@@ -63,10 +67,6 @@ Global{99B4CFE8-1441-4F0D-8C40-A70D0DD372ED}.Debug|Any CPU.Build.0 = Debug|Any CPU{99B4CFE8-1441-4F0D-8C40-A70D0DD372ED}.Release|Any CPU.ActiveCfg = Release|Any CPU{99B4CFE8-1441-4F0D-8C40-A70D0DD372ED}.Release|Any CPU.Build.0 = Release|Any CPU- {9B1DDD79-5134-4DF3-ACE3-D1957A7350D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU- {9B1DDD79-5134-4DF3-ACE3-D1957A7350D8}.Debug|Any CPU.Build.0 = Debug|Any CPU- {9B1DDD79-5134-4DF3-ACE3-D1957A7350D8}.Release|Any CPU.ActiveCfg = Release|Any CPU- {9B1DDD79-5134-4DF3-ACE3-D1957A7350D8}.Release|Any CPU.Build.0 = Release|Any CPUEndGlobalSectionGlobalSection(SolutionProperties) = preSolutionHideSolutionNode = FALSE