improve theme song methods

This commit is contained in:
Luke Pulverenti 2013-04-24 12:37:12 -04:00
parent 5f75f9ce87
commit 191befa788
4 changed files with 70 additions and 11 deletions

View File

@ -161,7 +161,7 @@ namespace MediaBrowser.Api.UserLibrary
public string Id { get; set; } public string Id { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this <see cref="UpdateUserItemRating"/> is likes. /// Gets or sets a value indicating whether this <see cref="UpdateUserItemRating" /> is likes.
/// </summary> /// </summary>
/// <value><c>true</c> if likes; otherwise, <c>false</c>.</value> /// <value><c>true</c> if likes; otherwise, <c>false</c>.</value>
[ApiMember(Name = "Likes", Description = "Whether the user likes the item or not. true/false", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")] [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; } public string Id { get; set; }
} }
/// <summary>
/// Class OnPlaybackStart
/// </summary>
[Route("/Users/{UserId}/PlayingItems/{Id}", "POST")] [Route("/Users/{UserId}/PlayingItems/{Id}", "POST")]
[Api(Description = "Reports that a user has begun playing an item")] [Api(Description = "Reports that a user has begun playing an item")]
public class OnPlaybackStart : IReturnVoid public class OnPlaybackStart : IReturnVoid
@ -231,6 +234,9 @@ namespace MediaBrowser.Api.UserLibrary
public string Id { get; set; } public string Id { get; set; }
} }
/// <summary>
/// Class OnPlaybackProgress
/// </summary>
[Route("/Users/{UserId}/PlayingItems/{Id}/Progress", "POST")] [Route("/Users/{UserId}/PlayingItems/{Id}/Progress", "POST")]
[Api(Description = "Reports a user's playback progress")] [Api(Description = "Reports a user's playback progress")]
public class OnPlaybackProgress : IReturnVoid public class OnPlaybackProgress : IReturnVoid
@ -257,6 +263,9 @@ namespace MediaBrowser.Api.UserLibrary
public long? PositionTicks { get; set; } public long? PositionTicks { get; set; }
} }
/// <summary>
/// Class OnPlaybackStopped
/// </summary>
[Route("/Users/{UserId}/PlayingItems/{Id}", "DELETE")] [Route("/Users/{UserId}/PlayingItems/{Id}", "DELETE")]
[Api(Description = "Reports that a user has stopped playing an item")] [Api(Description = "Reports that a user has stopped playing an item")]
public class OnPlaybackStopped : IReturnVoid 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")] [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; } public long? PositionTicks { get; set; }
} }
/// <summary> /// <summary>
/// Class GetLocalTrailers /// Class GetLocalTrailers
/// </summary> /// </summary>
@ -305,9 +314,12 @@ namespace MediaBrowser.Api.UserLibrary
public string Id { get; set; } public string Id { get; set; }
} }
/// <summary>
/// Class GetThemeSongs
/// </summary>
[Route("/Users/{UserId}/Items/{Id}/ThemeSongs", "GET")] [Route("/Users/{UserId}/Items/{Id}/ThemeSongs", "GET")]
[Api(Description = "Gets theme songs for an item")] [Api(Description = "Gets theme songs for an item")]
public class GetThemeSongs : IReturn<List<BaseItemDto>> public class GetThemeSongs : IReturn<ThemeSongsResult>
{ {
/// <summary> /// <summary>
/// Gets or sets the user id. /// Gets or sets the user id.
@ -356,12 +368,21 @@ namespace MediaBrowser.Api.UserLibrary
/// The _user manager /// The _user manager
/// </summary> /// </summary>
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
/// <summary>
/// The _user data repository
/// </summary>
private readonly IUserDataRepository _userDataRepository; private readonly IUserDataRepository _userDataRepository;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UserLibraryService" /> class. /// Initializes a new instance of the <see cref="UserLibraryService" /> class.
/// </summary> /// </summary>
/// <param name="userManager">The user manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception> /// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository) public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository)
: base() : base()
@ -431,9 +452,16 @@ namespace MediaBrowser.Api.UserLibrary
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository); 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);
} }
/// <summary> /// <summary>
@ -457,6 +485,11 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(result); return ToOptimizedResult(result);
} }
/// <summary>
/// Gets the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
public object Get(GetRootFolder request) public object Get(GetRootFolder request)
{ {
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
@ -472,7 +505,7 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(result); return ToOptimizedResult(result);
} }
/// <summary> /// <summary>
/// Gets the specified request. /// Gets the specified request.
/// </summary> /// </summary>
@ -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 item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var key = item.GetUserDataKey(); var key = item.GetUserDataKey();
// Get the user data for this item // Get the user data for this item
var data = _userDataRepository.GetUserData(user.Id, key).Result; 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 item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var key = item.GetUserDataKey(); var key = item.GetUserDataKey();
// Get the user data for this item // Get the user data for this item
var data = _userDataRepository.GetUserData(user.Id, key).Result; 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 item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var key = item.GetUserDataKey(); var key = item.GetUserDataKey();
// Get the user data for this item // Get the user data for this item
var data = _userDataRepository.GetUserData(user.Id, key).Result; var data = _userDataRepository.GetUserData(user.Id, key).Result;

View File

@ -84,6 +84,7 @@
<Compile Include="Net\NetworkShare.cs" /> <Compile Include="Net\NetworkShare.cs" />
<Compile Include="Net\NetworkShareType.cs" /> <Compile Include="Net\NetworkShareType.cs" />
<Compile Include="Querying\PersonsQuery.cs" /> <Compile Include="Querying\PersonsQuery.cs" />
<Compile Include="Querying\ThemeSongsResult.cs" />
<Compile Include="Serialization\IJsonSerializer.cs" /> <Compile Include="Serialization\IJsonSerializer.cs" />
<Compile Include="Serialization\IXmlSerializer.cs" /> <Compile Include="Serialization\IXmlSerializer.cs" />
<Compile Include="Updates\CheckForUpdateResult.cs" /> <Compile Include="Updates\CheckForUpdateResult.cs" />

View File

@ -0,0 +1,16 @@
using System;
namespace MediaBrowser.Model.Querying
{
/// <summary>
/// Class ThemeSongsResult
/// </summary>
public class ThemeSongsResult : ItemsResult
{
/// <summary>
/// Gets or sets the owner id.
/// </summary>
/// <value>The owner id.</value>
public string OwnerId { get; set; }
}
}

View File

@ -18,7 +18,6 @@ namespace MediaBrowser.Server.Implementations.Library
/// </summary> /// </summary>
private static readonly List<string> IgnoreFolders = new List<string> private static readonly List<string> IgnoreFolders = new List<string>
{ {
"trailers",
"metadata", "metadata",
"certificate", "certificate",
"backup", "backup",
@ -55,6 +54,16 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
return true; return true;
} }
if (string.Equals(filename, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (string.Equals(filename, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
{
return true;
}
} }
return false; return false;