using System; using System.Collections.Generic; using MediaBrowser.Controller; using MediaBrowser.Model.Entities; namespace MediaBrowser.Api { public static class ApiService { public static BaseItem GetItemById(string id) { Guid guid = string.IsNullOrEmpty(id) ? Guid.Empty : new Guid(id); return Kernel.Instance.GetItemById(guid); } public static IEnumerable GetAllStudios(Folder parent, Guid userId) { Dictionary data = new Dictionary(); IEnumerable allItems = Kernel.Instance.GetParentalAllowedRecursiveChildren(parent, userId); foreach (var item in allItems) { if (item.Studios == null) { continue; } foreach (string val in item.Studios) { if (!data.ContainsKey(val)) { data.Add(val, 1); } else { data[val]++; } } } List list = new List(); foreach (string key in data.Keys) { list.Add(new CategoryInfo() { Name = key, ItemCount = data[key] }); } return list; } public static IEnumerable GetAllGenres(Folder parent, Guid userId) { Dictionary data = new Dictionary(); IEnumerable allItems = Kernel.Instance.GetParentalAllowedRecursiveChildren(parent, userId); foreach (var item in allItems) { if (item.Genres == null) { continue; } foreach (string val in item.Genres) { if (!data.ContainsKey(val)) { data.Add(val, 1); } else { data[val]++; } } } List list = new List(); foreach (string key in data.Keys) { list.Add(new CategoryInfo() { Name = key, ItemCount = data[key] }); } return list; } } }