aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs19
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserViewManager.cs39
2 files changed, 20 insertions, 38 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 297d5e032..a3e86c667 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -1484,16 +1484,27 @@ namespace MediaBrowser.Server.Implementations.Library
.Distinct(StringComparer.OrdinalIgnoreCase);
}
- public async Task<UserView> GetNamedView(string name, string type, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetNamedView(string name, string type, string sortName, CancellationToken cancellationToken)
+ {
+ return GetNamedView(name, null, type, sortName, cancellationToken);
+ }
+
+ public async Task<UserView> GetNamedView(string name, string category, string type, string sortName, CancellationToken cancellationToken)
{
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
- "views",
- _fileSystem.GetValidFilename(type));
+ "views");
+
+ if (!string.IsNullOrWhiteSpace(category))
+ {
+ path = Path.Combine(path, _fileSystem.GetValidFilename(category));
+ }
+
+ path = Path.Combine(path, _fileSystem.GetValidFilename(type));
var id = (path + "_namedview_" + name).GetMBId(typeof(UserView));
var item = GetItemById(id) as UserView;
-
+
if (item == null)
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
index 63aa3764c..61283505b 100644
--- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.IO;
+using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities;
@@ -16,7 +15,6 @@ using MediaBrowser.Model.Library;
using MediaBrowser.Model.Querying;
using System;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -148,43 +146,16 @@ namespace MediaBrowser.Server.Implementations.Library
.ThenBy(i => i.SortName);
}
- public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetUserView(string category, string type, User user, string sortName, CancellationToken cancellationToken)
{
var name = _localizationManager.GetLocalizedString("ViewType" + type);
- return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
+ return _libraryManager.GetNamedView(name, category, type, sortName, cancellationToken);
}
- public async Task<SpecialFolder> GetSpecialFolder(string name, SpecialFolderType type, string itemType, CancellationToken cancellationToken)
+ public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
{
- var path = Path.Combine(_appPaths.ItemsByNamePath,
- "specialfolders",
- _fileSystem.GetValidFilename(name));
-
- var id = (path + "_specialfolder_" + name).GetMBId(typeof(SpecialFolder));
-
- var item = _libraryManager.GetItemById(id) as SpecialFolder;
-
- if (item == null)
- {
- Directory.CreateDirectory(Path.GetDirectoryName(path));
-
- item = new SpecialFolder
- {
- Path = path,
- Id = id,
- DateCreated = DateTime.UtcNow,
- Name = name,
- SpecialFolderType = type,
- ItemTypeName = itemType
- };
-
- await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
-
- await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
- }
-
- return item;
+ return GetUserView(null, type, user, sortName, cancellationToken);
}
}
}