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.cs65
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserViewManager.cs27
2 files changed, 54 insertions, 38 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 070b111ee..f6809c924 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -1584,15 +1584,22 @@ namespace MediaBrowser.Server.Implementations.Library
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
- public async Task<UserView> GetNamedView(string name,
- string type,
+ public async Task<UserView> GetNamedView(User user,
+ string name,
+ string viewType,
string sortName,
CancellationToken cancellationToken)
{
+ if (ConfigurationManager.Configuration.EnableUserSpecificUserViews)
+ {
+ return await GetNamedViewInternal(user, name, null, viewType, sortName, cancellationToken)
+ .ConfigureAwait(false);
+ }
+
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
"views");
- path = Path.Combine(path, _fileSystem.GetValidFilename(type));
+ path = Path.Combine(path, _fileSystem.GetValidFilename(viewType));
var id = GetNewItemId(path + "_namedview_" + name, typeof(UserView));
@@ -1611,7 +1618,7 @@ namespace MediaBrowser.Server.Implementations.Library
Id = id,
DateCreated = DateTime.UtcNow,
Name = name,
- ViewType = type,
+ ViewType = viewType,
ForcedSortName = sortName
};
@@ -1627,31 +1634,38 @@ namespace MediaBrowser.Server.Implementations.Library
if (refresh)
{
- await item.RefreshMetadata(new MetadataRefreshOptions
- {
- ForceSave = true
-
- }, cancellationToken).ConfigureAwait(false);
+ await item.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None).ConfigureAwait(false);
+ _providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions());
}
return item;
}
- public async Task<UserView> GetSpecialFolder(User user,
+ public Task<UserView> GetNamedView(User user,
string name,
string parentId,
string viewType,
string sortName,
CancellationToken cancellationToken)
{
- if (string.IsNullOrWhiteSpace(name))
+ if (string.IsNullOrWhiteSpace(parentId))
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException("parentId");
}
- if (string.IsNullOrWhiteSpace(parentId))
+ return GetNamedViewInternal(user, name, parentId, viewType, sortName, cancellationToken);
+ }
+
+ private async Task<UserView> GetNamedViewInternal(User user,
+ string name,
+ string parentId,
+ string viewType,
+ string sortName,
+ CancellationToken cancellationToken)
+ {
+ if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentNullException("parentId");
+ throw new ArgumentNullException("name");
}
if (string.IsNullOrWhiteSpace(viewType))
@@ -1659,9 +1673,9 @@ namespace MediaBrowser.Server.Implementations.Library
throw new ArgumentNullException("viewType");
}
- var id = GetNewItemId("7_namedview_" + name + user.Id.ToString("N") + parentId, typeof(UserView));
+ var id = GetNewItemId("23_namedview_" + name + user.Id.ToString("N") + (parentId ?? string.Empty), typeof(UserView));
- var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", "specialviews", id.ToString("N"));
+ var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N"));
var item = GetItemById(id) as UserView;
@@ -1679,27 +1693,28 @@ namespace MediaBrowser.Server.Implementations.Library
Name = name,
ViewType = viewType,
ForcedSortName = sortName,
- UserId = user.Id,
- ParentId = new Guid(parentId)
+ UserId = user.Id
};
+ if (!string.IsNullOrWhiteSpace(parentId))
+ {
+ item.ParentId = new Guid(parentId);
+ }
+
await CreateItem(item, cancellationToken).ConfigureAwait(false);
refresh = true;
}
- if (!refresh && item != null)
+ if (!refresh)
{
refresh = (DateTime.UtcNow - item.DateLastSaved).TotalHours >= 24;
}
if (refresh)
{
- await item.RefreshMetadata(new MetadataRefreshOptions
- {
- ForceSave = true
-
- }, cancellationToken).ConfigureAwait(false);
+ await item.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None).ConfigureAwait(false);
+ _providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions());
}
return item;
@@ -1849,7 +1864,7 @@ namespace MediaBrowser.Server.Implementations.Library
// These cause apps to have problems
options.AudioFileExtensions.Remove(".m3u");
options.AudioFileExtensions.Remove(".wpl");
-
+
if (!ConfigurationManager.Configuration.EnableAudioArchiveFiles)
{
options.AudioFileExtensions.Remove(".rar");
diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
index 8b7cfa9f2..a583534ee 100644
--- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
@@ -70,40 +70,41 @@ namespace MediaBrowser.Server.Implementations.Library
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) ||
foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType)))
{
- list.Add(await GetUserView(CollectionType.TvShows, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.TvShows, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) ||
foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)))
{
- list.Add(await GetUserView(CollectionType.Music, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Music, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) ||
foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType)))
{
- list.Add(await GetUserView(CollectionType.Movies, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Movies, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)))
{
- list.Add(await GetUserView(CollectionType.Games, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Games, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)))
{
//list.Add(_collectionManager.GetCollectionsFolder(user.Id.ToString("N")));
- list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)))
{
- list.Add(_playlists.GetPlaylistsFolder(user.Id.ToString("N")));
+ //list.Add(_playlists.GetPlaylistsFolder(user.Id.ToString("N")));
+ list.Add(await GetUserView(CollectionType.Playlists, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
if (user.Configuration.DisplayFoldersView)
{
- list.Add(await GetUserView(CollectionType.Folders, "zz_" + CollectionType.Folders, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Folders, "zz_" + CollectionType.Folders, user, cancellationToken).ConfigureAwait(false));
}
if (query.IncludeExternalContent)
@@ -148,23 +149,23 @@ namespace MediaBrowser.Server.Implementations.Library
.ThenBy(i => i.SortName);
}
- public Task<UserView> GetUserView(string name, string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetUserSubView(string name, string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
{
- return _libraryManager.GetSpecialFolder(user, name, parentId, type, sortName, cancellationToken);
+ return _libraryManager.GetNamedView(user, name, parentId, type, sortName, cancellationToken);
}
- public Task<UserView> GetUserView(string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetUserSubView(string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
{
var name = _localizationManager.GetLocalizedString("ViewType" + type);
- return GetUserView(name, parentId, type, user, sortName, cancellationToken);
+ return GetUserSubView(name, parentId, type, user, sortName, cancellationToken);
}
- public Task<UserView> GetUserView(string type, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetUserView(string type, string sortName, User user, CancellationToken cancellationToken)
{
var name = _localizationManager.GetLocalizedString("ViewType" + type);
- return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
+ return _libraryManager.GetNamedView(user, name, type, sortName, cancellationToken);
}
public List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request)