From 191befa7888bae6c4f4265200aa2bc0e1e96fbf1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 24 Apr 2013 12:37:12 -0400 Subject: [PATCH] improve theme song methods --- .../UserLibrary/UserLibraryService.cs | 53 +++++++++++++++---- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../Querying/ThemeSongsResult.cs | 16 ++++++ .../Library/CoreResolutionIgnoreRule.cs | 11 +++- 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 MediaBrowser.Model/Querying/ThemeSongsResult.cs diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index cd42c99ea..22212d287 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -161,7 +161,7 @@ namespace MediaBrowser.Api.UserLibrary public string Id { get; set; } /// - /// Gets or sets a value indicating whether this is likes. + /// Gets or sets a value indicating whether this is likes. /// /// true if likes; otherwise, false. [ApiMember(Name = "Likes", Description = "Whether the user likes the item or not. true/false", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")] @@ -212,6 +212,9 @@ namespace MediaBrowser.Api.UserLibrary public string Id { get; set; } } + /// + /// Class OnPlaybackStart + /// [Route("/Users/{UserId}/PlayingItems/{Id}", "POST")] [Api(Description = "Reports that a user has begun playing an item")] public class OnPlaybackStart : IReturnVoid @@ -231,6 +234,9 @@ namespace MediaBrowser.Api.UserLibrary public string Id { get; set; } } + /// + /// Class OnPlaybackProgress + /// [Route("/Users/{UserId}/PlayingItems/{Id}/Progress", "POST")] [Api(Description = "Reports a user's playback progress")] public class OnPlaybackProgress : IReturnVoid @@ -257,6 +263,9 @@ namespace MediaBrowser.Api.UserLibrary public long? PositionTicks { get; set; } } + /// + /// Class OnPlaybackStopped + /// [Route("/Users/{UserId}/PlayingItems/{Id}", "DELETE")] [Api(Description = "Reports that a user has stopped playing an item")] public class OnPlaybackStopped : IReturnVoid @@ -282,7 +291,7 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "PositionTicks", Description = "Optional. The position, in ticks, where playback stopped. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "DELETE")] public long? PositionTicks { get; set; } } - + /// /// Class GetLocalTrailers /// @@ -305,9 +314,12 @@ namespace MediaBrowser.Api.UserLibrary public string Id { get; set; } } + /// + /// Class GetThemeSongs + /// [Route("/Users/{UserId}/Items/{Id}/ThemeSongs", "GET")] [Api(Description = "Gets theme songs for an item")] - public class GetThemeSongs : IReturn> + public class GetThemeSongs : IReturn { /// /// Gets or sets the user id. @@ -356,12 +368,21 @@ namespace MediaBrowser.Api.UserLibrary /// The _user manager /// private readonly IUserManager _userManager; + /// + /// The _user data repository + /// private readonly IUserDataRepository _userDataRepository; + /// + /// The _library manager + /// private readonly ILibraryManager _libraryManager; - + /// /// Initializes a new instance of the class. /// + /// The user manager. + /// The library manager. + /// The user data repository. /// jsonSerializer public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository) : base() @@ -431,9 +452,16 @@ namespace MediaBrowser.Api.UserLibrary var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository); - var items = item.ThemeSongs.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).AsParallel().Select(t => t.Result).ToList(); + var items = item.ThemeSongs.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).AsParallel().Select(t => t.Result).ToArray(); - return ToOptimizedResult(items); + var result = new ThemeSongsResult + { + Items = items, + TotalRecordCount = items.Length, + OwnerId = DtoBuilder.GetClientItemId(item) + }; + + return ToOptimizedResult(result); } /// @@ -457,6 +485,11 @@ namespace MediaBrowser.Api.UserLibrary return ToOptimizedResult(result); } + /// + /// Gets the specified request. + /// + /// The request. + /// System.Object. public object Get(GetRootFolder request) { var user = _userManager.GetUserById(request.UserId); @@ -472,7 +505,7 @@ namespace MediaBrowser.Api.UserLibrary return ToOptimizedResult(result); } - + /// /// Gets the specified request. /// @@ -523,7 +556,7 @@ namespace MediaBrowser.Api.UserLibrary var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var key = item.GetUserDataKey(); - + // Get the user data for this item var data = _userDataRepository.GetUserData(user.Id, key).Result; @@ -546,7 +579,7 @@ namespace MediaBrowser.Api.UserLibrary var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var key = item.GetUserDataKey(); - + // Get the user data for this item var data = _userDataRepository.GetUserData(user.Id, key).Result; @@ -568,7 +601,7 @@ namespace MediaBrowser.Api.UserLibrary var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id); var key = item.GetUserDataKey(); - + // Get the user data for this item var data = _userDataRepository.GetUserData(user.Id, key).Result; diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 41aa86693..8e29d302c 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -84,6 +84,7 @@ + diff --git a/MediaBrowser.Model/Querying/ThemeSongsResult.cs b/MediaBrowser.Model/Querying/ThemeSongsResult.cs new file mode 100644 index 000000000..d1319f6e1 --- /dev/null +++ b/MediaBrowser.Model/Querying/ThemeSongsResult.cs @@ -0,0 +1,16 @@ +using System; + +namespace MediaBrowser.Model.Querying +{ + /// + /// Class ThemeSongsResult + /// + public class ThemeSongsResult : ItemsResult + { + /// + /// Gets or sets the owner id. + /// + /// The owner id. + public string OwnerId { get; set; } + } +} diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index a120f074e..04c247f7e 100644 --- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -18,7 +18,6 @@ namespace MediaBrowser.Server.Implementations.Library /// private static readonly List IgnoreFolders = new List { - "trailers", "metadata", "certificate", "backup", @@ -55,6 +54,16 @@ namespace MediaBrowser.Server.Implementations.Library { return true; } + + if (string.Equals(filename, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + if (string.Equals(filename, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase)) + { + return true; + } } return false;