diff options
Diffstat (limited to 'MediaBrowser.Api/ApiService.cs')
| -rw-r--r-- | MediaBrowser.Api/ApiService.cs | 101 |
1 files changed, 70 insertions, 31 deletions
diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs index b0cc54fee..2687ce81a 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;
}
}
}
|
