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

@ -212,6 +212,9 @@ namespace MediaBrowser.Api.UserLibrary
public string Id { get; set; }
}
/// <summary>
/// Class OnPlaybackStart
/// </summary>
[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; }
}
/// <summary>
/// Class OnPlaybackProgress
/// </summary>
[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; }
}
/// <summary>
/// Class OnPlaybackStopped
/// </summary>
[Route("/Users/{UserId}/PlayingItems/{Id}", "DELETE")]
[Api(Description = "Reports that a user has stopped playing an item")]
public class OnPlaybackStopped : IReturnVoid
@ -305,9 +314,12 @@ namespace MediaBrowser.Api.UserLibrary
public string Id { get; set; }
}
/// <summary>
/// Class GetThemeSongs
/// </summary>
[Route("/Users/{UserId}/Items/{Id}/ThemeSongs", "GET")]
[Api(Description = "Gets theme songs for an item")]
public class GetThemeSongs : IReturn<List<BaseItemDto>>
public class GetThemeSongs : IReturn<ThemeSongsResult>
{
/// <summary>
/// Gets or sets the user id.
@ -356,12 +368,21 @@ namespace MediaBrowser.Api.UserLibrary
/// The _user manager
/// </summary>
private readonly IUserManager _userManager;
/// <summary>
/// The _user data repository
/// </summary>
private readonly IUserDataRepository _userDataRepository;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
/// <summary>
/// Initializes a new instance of the <see cref="UserLibraryService" /> class.
/// </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>
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);
}
/// <summary>
@ -457,6 +485,11 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(result);
}
/// <summary>
/// Gets the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
public object Get(GetRootFolder request)
{
var user = _userManager.GetUserById(request.UserId);

View File

@ -84,6 +84,7 @@
<Compile Include="Net\NetworkShare.cs" />
<Compile Include="Net\NetworkShareType.cs" />
<Compile Include="Querying\PersonsQuery.cs" />
<Compile Include="Querying\ThemeSongsResult.cs" />
<Compile Include="Serialization\IJsonSerializer.cs" />
<Compile Include="Serialization\IXmlSerializer.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>
private static readonly List<string> IgnoreFolders = new List<string>
{
"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;