|
|
|
@ -1,5 +1,3 @@
|
|
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
@ -23,6 +21,7 @@ using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace Emby.Server.Implementations.Collections
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public class CollectionManager : ICollectionManager
|
|
|
|
|
{
|
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
@ -33,6 +32,16 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
private readonly ILocalizationManager _localizationManager;
|
|
|
|
|
private readonly IApplicationPaths _appPaths;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="CollectionManager"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
|
|
|
/// <param name="appPaths">The application paths.</param>
|
|
|
|
|
/// <param name="localizationManager">The localization manager.</param>
|
|
|
|
|
/// <param name="fileSystem">The filesystem.</param>
|
|
|
|
|
/// <param name="iLibraryMonitor">The library monitor.</param>
|
|
|
|
|
/// <param name="loggerFactory">The logger factory.</param>
|
|
|
|
|
/// <param name="providerManager">The provider manager.</param>
|
|
|
|
|
public CollectionManager(
|
|
|
|
|
ILibraryManager libraryManager,
|
|
|
|
|
IApplicationPaths appPaths,
|
|
|
|
@ -51,8 +60,13 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
_appPaths = appPaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public event EventHandler<CollectionCreatedEventArgs> CollectionCreated;
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public event EventHandler<CollectionModifiedEventArgs> ItemsAddedToCollection;
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public event EventHandler<CollectionModifiedEventArgs> ItemsRemovedFromCollection;
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Folder> FindFolders(string path)
|
|
|
|
@ -114,6 +128,7 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
folder.GetChildren(user, true).OfType<BoxSet>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public BoxSet CreateCollection(CollectionCreationOptions options)
|
|
|
|
|
{
|
|
|
|
|
var name = options.Name;
|
|
|
|
@ -178,11 +193,13 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void AddToCollection(Guid collectionId, IEnumerable<string> ids)
|
|
|
|
|
{
|
|
|
|
|
AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(new DirectoryService(_fileSystem)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void AddToCollection(Guid collectionId, IEnumerable<Guid> ids)
|
|
|
|
|
{
|
|
|
|
|
AddToCollection(collectionId, ids.Select(i => i.ToString("N", CultureInfo.InvariantCulture)), true, new MetadataRefreshOptions(new DirectoryService(_fileSystem)));
|
|
|
|
@ -246,11 +263,13 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void RemoveFromCollection(Guid collectionId, IEnumerable<string> itemIds)
|
|
|
|
|
{
|
|
|
|
|
RemoveFromCollection(collectionId, itemIds.Select(i => new Guid(i)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void RemoveFromCollection(Guid collectionId, IEnumerable<Guid> itemIds)
|
|
|
|
|
{
|
|
|
|
|
var collection = _libraryManager.GetItemById(collectionId) as BoxSet;
|
|
|
|
@ -301,6 +320,7 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user)
|
|
|
|
|
{
|
|
|
|
|
var results = new Dictionary<Guid, BaseItem>();
|
|
|
|
@ -309,9 +329,7 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
var grouping = item as ISupportsBoxSetGrouping;
|
|
|
|
|
|
|
|
|
|
if (grouping == null)
|
|
|
|
|
if (!(item is ISupportsBoxSetGrouping))
|
|
|
|
|
{
|
|
|
|
|
results[item.Id] = item;
|
|
|
|
|
}
|
|
|
|
@ -341,12 +359,21 @@ namespace Emby.Server.Implementations.Collections
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The collection manager entry point.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class CollectionManagerEntryPoint : IServerEntryPoint
|
|
|
|
|
{
|
|
|
|
|
private readonly CollectionManager _collectionManager;
|
|
|
|
|
private readonly IServerConfigurationManager _config;
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="CollectionManagerEntryPoint"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="collectionManager">The collection manager.</param>
|
|
|
|
|
/// <param name="config">The server configuration manager.</param>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
|
|
|
|
public CollectionManagerEntryPoint(
|
|
|
|
|
ICollectionManager collectionManager,
|
|
|
|
|
IServerConfigurationManager config,
|
|
|
|
|