aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library/LibraryService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-14 16:35:09 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-14 16:35:09 -0500
commitdaa0b6cd0ecefd60611752802d062c15e6da85de (patch)
treef58a16e47afed9b61471e3871280faa9fc8bd951 /MediaBrowser.Api/Library/LibraryService.cs
parent7d26b8995f313917829573a7cd96c37decc9158a (diff)
parentfd5f12e76227d96c52cdc31b67ef9543b485169b (diff)
Merge branch 'beta'
Diffstat (limited to 'MediaBrowser.Api/Library/LibraryService.cs')
-rw-r--r--MediaBrowser.Api/Library/LibraryService.cs70
1 files changed, 56 insertions, 14 deletions
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs
index b7066a36d..896f8c990 100644
--- a/MediaBrowser.Api/Library/LibraryService.cs
+++ b/MediaBrowser.Api/Library/LibraryService.cs
@@ -424,7 +424,7 @@ namespace MediaBrowser.Api.Library
public object Get(GetMediaFolders request)
{
- var items = _libraryManager.GetUserRootFolder().Children.OrderBy(i => i.SortName).ToList();
+ var items = _libraryManager.GetUserRootFolder().Children.Concat(_libraryManager.RootFolder.VirtualChildren).OrderBy(i => i.SortName).ToList();
if (request.IsHidden.HasValue)
{
@@ -569,7 +569,7 @@ namespace MediaBrowser.Api.Library
{
throw new ArgumentException("This command cannot be used for remote or virtual items.");
}
- if (_fileSystem.DirectoryExists(item.Path))
+ if (_fileSystem.DirectoryExists(item.Path))
{
throw new ArgumentException("This command cannot be used for directories.");
}
@@ -618,7 +618,7 @@ namespace MediaBrowser.Api.Library
var dtoOptions = GetDtoOptions(request);
- BaseItem parent = item.Parent;
+ BaseItem parent = item.GetParent();
while (parent != null)
{
@@ -629,7 +629,7 @@ namespace MediaBrowser.Api.Library
baseItemDtos.Add(_dtoService.GetBaseItemDto(parent, dtoOptions, user));
- parent = parent.Parent;
+ parent = parent.GetParent();
}
return baseItemDtos.ToList();
@@ -637,7 +637,7 @@ namespace MediaBrowser.Api.Library
private BaseItem TranslateParentItem(BaseItem item, User user)
{
- if (item.Parent is AggregateFolder)
+ if (item.GetParent() is AggregateFolder)
{
return user.RootFolder.GetChildren(user, true).FirstOrDefault(i => i.PhysicalLocations.Contains(item.Path));
}
@@ -685,6 +685,50 @@ namespace MediaBrowser.Api.Library
return ToOptimizedSerializedResultUsingCache(counts);
}
+ private IList<BaseItem> GetAllLibraryItems(string userId, IUserManager userManager, ILibraryManager libraryManager, string parentId, Func<BaseItem, bool> filter)
+ {
+ if (!string.IsNullOrEmpty(parentId))
+ {
+ var folder = (Folder)libraryManager.GetItemById(new Guid(parentId));
+
+ if (!string.IsNullOrWhiteSpace(userId))
+ {
+ var user = userManager.GetUserById(userId);
+
+ if (user == null)
+ {
+ throw new ArgumentException("User not found");
+ }
+
+ return folder
+ .GetRecursiveChildren(user, filter)
+ .ToList();
+ }
+
+ return folder
+ .GetRecursiveChildren(filter);
+ }
+ if (!string.IsNullOrWhiteSpace(userId))
+ {
+ var user = userManager.GetUserById(userId);
+
+ if (user == null)
+ {
+ throw new ArgumentException("User not found");
+ }
+
+ return userManager
+ .GetUserById(userId)
+ .RootFolder
+ .GetRecursiveChildren(user, filter)
+ .ToList();
+ }
+
+ return libraryManager
+ .RootFolder
+ .GetRecursiveChildren(filter);
+ }
+
private bool FilterItem(BaseItem item, GetItemCounts request, string userId)
{
if (!string.IsNullOrWhiteSpace(userId))
@@ -745,12 +789,10 @@ namespace MediaBrowser.Api.Library
return Task.FromResult(true);
}
- if (item is ILiveTvRecording)
+ return item.Delete(new DeleteOptions
{
- return _liveTv.DeleteRecording(i);
- }
-
- return _libraryManager.DeleteItem(item);
+ DeleteFileLocation = true
+ });
}).ToArray();
Task.WaitAll(tasks);
@@ -847,9 +889,9 @@ namespace MediaBrowser.Api.Library
: (Folder)_libraryManager.RootFolder)
: _libraryManager.GetItemById(request.Id);
- while (GetThemeSongIds(item).Count == 0 && request.InheritFromParent && item.Parent != null)
+ while (GetThemeSongIds(item).Count == 0 && request.InheritFromParent && item.GetParent() != null)
{
- item = item.Parent;
+ item = item.GetParent();
}
var dtoOptions = GetDtoOptions(request);
@@ -890,9 +932,9 @@ namespace MediaBrowser.Api.Library
: (Folder)_libraryManager.RootFolder)
: _libraryManager.GetItemById(request.Id);
- while (GetThemeVideoIds(item).Count == 0 && request.InheritFromParent && item.Parent != null)
+ while (GetThemeVideoIds(item).Count == 0 && request.InheritFromParent && item.GetParent() != null)
{
- item = item.Parent;
+ item = item.GetParent();
}
var dtoOptions = GetDtoOptions(request);