|
|
@ -173,7 +173,8 @@ namespace MediaBrowser.Api
|
|
|
|
/// <param name="itemRepo">The item repo.</param>
|
|
|
|
/// <param name="itemRepo">The item repo.</param>
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
|
|
/// <param name="userManager">The user manager.</param>
|
|
|
|
/// <param name="userManager">The user manager.</param>
|
|
|
|
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, IUserDataRepository userDataRepository)
|
|
|
|
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
|
|
|
|
|
|
|
|
IUserDataRepository userDataRepository)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_itemRepo = itemRepo;
|
|
|
|
_itemRepo = itemRepo;
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
_libraryManager = libraryManager;
|
|
|
@ -236,7 +237,9 @@ namespace MediaBrowser.Api
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None).ConfigureAwait(false);
|
|
|
|
await
|
|
|
|
|
|
|
|
_libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None)
|
|
|
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -269,7 +272,9 @@ namespace MediaBrowser.Api
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await parent.ValidateChildren(new Progress<double>(), CancellationToken.None).ConfigureAwait(false);
|
|
|
|
await
|
|
|
|
|
|
|
|
parent.ValidateChildren(new Progress<double>(), CancellationToken.None)
|
|
|
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -333,16 +338,26 @@ namespace MediaBrowser.Api
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
|
|
|
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
|
|
|
|
|
|
|
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ?
|
|
|
|
var item = string.IsNullOrEmpty(request.Id)
|
|
|
|
(request.UserId.HasValue ? user.RootFolder :
|
|
|
|
? (request.UserId.HasValue
|
|
|
|
(Folder)_libraryManager.RootFolder) : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
|
|
|
|
? user.RootFolder
|
|
|
|
|
|
|
|
: (Folder)_libraryManager.RootFolder)
|
|
|
|
|
|
|
|
: DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
|
|
|
|
|
|
|
|
|
|
|
|
// Get everything
|
|
|
|
// Get everything
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
var fields =
|
|
|
|
|
|
|
|
Enum.GetNames(typeof(ItemFields))
|
|
|
|
|
|
|
|
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
|
|
|
|
|
|
|
|
|
|
|
var items = _itemRepo.GetItems(item.ThemeSongIds).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToArray();
|
|
|
|
var items =
|
|
|
|
|
|
|
|
_itemRepo.GetItems(item.ThemeSongIds)
|
|
|
|
|
|
|
|
.OrderBy(i => i.SortName)
|
|
|
|
|
|
|
|
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user))
|
|
|
|
|
|
|
|
.Select(t => t.Result)
|
|
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
var result = new ThemeSongsResult
|
|
|
|
var result = new ThemeSongsResult
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -363,16 +378,26 @@ namespace MediaBrowser.Api
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
|
|
|
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
|
|
|
|
|
|
|
|
|
|
|
var item = string.IsNullOrEmpty(request.Id) ?
|
|
|
|
var item = string.IsNullOrEmpty(request.Id)
|
|
|
|
(request.UserId.HasValue ? user.RootFolder :
|
|
|
|
? (request.UserId.HasValue
|
|
|
|
(Folder)_libraryManager.RootFolder) : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
|
|
|
|
? user.RootFolder
|
|
|
|
|
|
|
|
: (Folder)_libraryManager.RootFolder)
|
|
|
|
|
|
|
|
: DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
|
|
|
|
|
|
|
|
|
|
|
|
// Get everything
|
|
|
|
// Get everything
|
|
|
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
|
|
var fields =
|
|
|
|
|
|
|
|
Enum.GetNames(typeof(ItemFields))
|
|
|
|
|
|
|
|
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
|
|
|
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository);
|
|
|
|
|
|
|
|
|
|
|
|
var items = _itemRepo.GetItems(item.ThemeVideoIds).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToArray();
|
|
|
|
var items =
|
|
|
|
|
|
|
|
_itemRepo.GetItems(item.ThemeVideoIds)
|
|
|
|
|
|
|
|
.OrderBy(i => i.SortName)
|
|
|
|
|
|
|
|
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user))
|
|
|
|
|
|
|
|
.Select(t => t.Result)
|
|
|
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
var result = new ThemeVideosResult
|
|
|
|
var result = new ThemeVideosResult
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -388,7 +413,14 @@ namespace MediaBrowser.Api
|
|
|
|
/// Posts the specified request.
|
|
|
|
/// Posts the specified request.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
public async void Post(RefreshItem request)
|
|
|
|
public void Post(RefreshItem request)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var task = RefreshItem(request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task RefreshItem(RefreshItem request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
|
|
|
|
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
|
|
|
|
|
|
|
|
|
|
|
@ -398,11 +430,14 @@ namespace MediaBrowser.Api
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (folder != null)
|
|
|
|
if (folder != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive, request.Forced).ConfigureAwait(false);
|
|
|
|
await
|
|
|
|
|
|
|
|
folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive,
|
|
|
|
|
|
|
|
request.Forced).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
|
|
|
await
|
|
|
|
|
|
|
|
item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|