aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/UserViewsService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/UserViewsService.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/UserViewsService.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/MediaBrowser.Api/UserLibrary/UserViewsService.cs b/MediaBrowser.Api/UserLibrary/UserViewsService.cs
index a49ab8556..9d7c38d6f 100644
--- a/MediaBrowser.Api/UserLibrary/UserViewsService.cs
+++ b/MediaBrowser.Api/UserLibrary/UserViewsService.cs
@@ -39,6 +39,17 @@ namespace MediaBrowser.Api.UserLibrary
public string UserId { get; set; }
}
+ [Route("/Users/{UserId}/GroupingOptions", "GET")]
+ public class GetGroupingOptions : IReturn<List<SpecialViewOption>>
+ {
+ /// <summary>
+ /// Gets or sets the user id.
+ /// </summary>
+ /// <value>The user id.</value>
+ [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string UserId { get; set; }
+ }
+
public class UserViewsService : BaseApiService
{
private readonly IUserManager _userManager;
@@ -105,6 +116,29 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(list);
}
+ public async Task<object> Get(GetGroupingOptions request)
+ {
+ var user = _userManager.GetUserById(request.UserId);
+
+ var views = user.RootFolder
+ .GetChildren(user, true)
+ .OfType<Folder>()
+ .Where(i => !UserView.IsExcludedFromGrouping(i))
+ .ToList();
+
+ var list = views
+ .Select(i => new SpecialViewOption
+ {
+ Name = i.Name,
+ Id = i.Id.ToString("N")
+
+ })
+ .OrderBy(i => i.Name)
+ .ToList();
+
+ return ToOptimizedResult(list);
+ }
+
private bool IsEligibleForSpecialView(ICollectionFolder view)
{
var types = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Games, CollectionType.Music, CollectionType.Photos };