mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 10:04:44 +01:00
added new parent methods
This commit is contained in:
@@ -27,6 +27,7 @@ using MediaBrowser.Server.Implementations.Library.Validators;
|
||||
using MediaBrowser.Server.Implementations.Logging;
|
||||
using MediaBrowser.Server.Implementations.ScheduledTasks;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -36,6 +37,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MoreLinq;
|
||||
using SortOrder = MediaBrowser.Model.Entities.SortOrder;
|
||||
|
||||
@@ -140,6 +142,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
private readonly Func<ILibraryMonitor> _libraryMonitorFactory;
|
||||
private readonly Func<IProviderManager> _providerManagerFactory;
|
||||
private readonly Func<IUserViewManager> _userviewManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _library items cache
|
||||
@@ -167,7 +170,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <param name="userDataRepository">The user data repository.</param>
|
||||
public LibraryManager(ILogger logger, ITaskManager taskManager, IUserManager userManager, IServerConfigurationManager configurationManager, IUserDataManager userDataRepository, Func<ILibraryMonitor> libraryMonitorFactory, IFileSystem fileSystem, Func<IProviderManager> providerManagerFactory)
|
||||
public LibraryManager(ILogger logger, ITaskManager taskManager, IUserManager userManager, IServerConfigurationManager configurationManager, IUserDataManager userDataRepository, Func<ILibraryMonitor> libraryMonitorFactory, IFileSystem fileSystem, Func<IProviderManager> providerManagerFactory, Func<IUserViewManager> userviewManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_taskManager = taskManager;
|
||||
@@ -177,6 +180,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
_libraryMonitorFactory = libraryMonitorFactory;
|
||||
_fileSystem = fileSystem;
|
||||
_providerManagerFactory = providerManagerFactory;
|
||||
_userviewManager = userviewManager;
|
||||
ByReferenceItems = new ConcurrentDictionary<Guid, BaseItem>();
|
||||
_libraryItemsCache = new ConcurrentDictionary<Guid, BaseItem>();
|
||||
|
||||
@@ -1307,7 +1311,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return ItemRepository.GetItemIdsList(query);
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetItems(InternalItemsQuery query, User user, IEnumerable<string> parentIds)
|
||||
public IEnumerable<BaseItem> GetItems(InternalItemsQuery query, IEnumerable<string> parentIds)
|
||||
{
|
||||
var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
|
||||
|
||||
@@ -1329,7 +1333,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
if (query.AncestorIds.Length == 0 && !query.ParentId.HasValue && query.ChannelIds.Length == 0)
|
||||
{
|
||||
// TODO: Need to filter on user folders
|
||||
//var userViews = _userviewManager().GetUserViews(new UserViewQuery
|
||||
//{
|
||||
// UserId = user.Id.ToString("N"),
|
||||
// IncludeHidden = true
|
||||
|
||||
//}, CancellationToken.None).Result.ToList();
|
||||
|
||||
//query.AncestorIds = userViews.SelectMany(i => i.GetIdsForAncestorQuery()).Distinct().Select(i => i.ToString("N")).ToArray();
|
||||
}
|
||||
|
||||
// TODO: handle blocking by tags
|
||||
@@ -1634,9 +1645,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
public IEnumerable<Folder> GetCollectionFolders(BaseItem item)
|
||||
{
|
||||
while (!(item.Parent is AggregateFolder) && item.Parent != null)
|
||||
while (!(item.GetParent() is AggregateFolder) && item.GetParent() != null)
|
||||
{
|
||||
item = item.Parent;
|
||||
item = item.GetParent();
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
@@ -1673,7 +1684,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return type;
|
||||
}
|
||||
|
||||
return item.Parents
|
||||
return item.GetParents()
|
||||
.Select(GetConfiguredContentType)
|
||||
.LastOrDefault(i => !string.IsNullOrWhiteSpace(i));
|
||||
}
|
||||
@@ -1710,9 +1721,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
private string GetTopFolderContentType(BaseItem item)
|
||||
{
|
||||
while (!(item.Parent is AggregateFolder) && item.Parent != null)
|
||||
while (!(item.GetParent() is AggregateFolder) && item.GetParent() != null)
|
||||
{
|
||||
item = item.Parent;
|
||||
item = item.GetParent();
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
Genres = genreList.ToArray()
|
||||
|
||||
}, user, new string[] { });
|
||||
}, new string[] { });
|
||||
|
||||
var genresDictionary = genreList.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());
|
||||
|
||||
item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
item.Parents.Any(i => i.IsLocked);
|
||||
item.GetParents().Any(i => i.IsLocked);
|
||||
|
||||
// Make sure DateCreated and DateModified have values
|
||||
var fileInfo = directoryService.GetFile(item.Path);
|
||||
@@ -78,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
EnsureName(item, args.FileInfo);
|
||||
|
||||
item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
item.Parents.Any(i => i.IsLocked);
|
||||
item.GetParents().Any(i => i.IsLocked);
|
||||
|
||||
// Make sure DateCreated and DateModified have values
|
||||
EnsureDates(fileSystem, item, args, true);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
return ResolveVideos<Video>(parent, files, directoryService, false);
|
||||
}
|
||||
|
||||
if (parent is Series || parent.Parents.OfType<Series>().Any())
|
||||
if (parent is Series || parent.GetParents().OfType<Series>().Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
// Not officially supported but in some cases we can handle it.
|
||||
if (season == null)
|
||||
{
|
||||
season = parent.Parents.OfType<Season>().FirstOrDefault();
|
||||
season = parent.GetParents().OfType<Season>().FirstOrDefault();
|
||||
}
|
||||
|
||||
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
IncludeItemTypes = includeItemTypes.ToArray(),
|
||||
Limit = query.Limit,
|
||||
|
||||
}, user, new string[] { });
|
||||
}, new string[] { });
|
||||
|
||||
// Add search hints based on item name
|
||||
hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item =>
|
||||
|
||||
@@ -49,6 +49,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
.OfType<Folder>()
|
||||
.ToList();
|
||||
|
||||
if (!query.IncludeHidden)
|
||||
{
|
||||
folders = folders.Where(i =>
|
||||
{
|
||||
var hidden = i as IHiddenFromDisplay;
|
||||
return hidden == null || !hidden.IsHiddenFromUser(user);
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
var plainFolderIds = user.Configuration.PlainFolderViews.Select(i => new Guid(i)).ToList();
|
||||
|
||||
var standaloneFolders = folders
|
||||
@@ -121,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
if (parents.Count > 0)
|
||||
{
|
||||
list.Add(await GetUserView(parents, list, CollectionType.TvShows, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(parents, CollectionType.TvShows, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
|
||||
@@ -129,7 +138,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
if (parents.Count > 0)
|
||||
{
|
||||
list.Add(await GetUserView(parents, list, CollectionType.Movies, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(parents, CollectionType.Movies, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
if (user.Configuration.DisplayFoldersView)
|
||||
@@ -194,7 +203,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return GetUserSubView(name, parentId, type, sortName, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<UserView> GetUserView(List<ICollectionFolder> parents, List<Folder> currentViews, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken)
|
||||
private async Task<UserView> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken)
|
||||
{
|
||||
if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
@@ -305,7 +314,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
||||
Limit = limit * 20
|
||||
|
||||
}, user, parentIds);
|
||||
}, parentIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user