mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
#715 - Support creating/editing collections (boxsets) in web client
This commit is contained in:
@@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Collections
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public Guid ParentId { get; set; }
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
public bool IsLocked { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Collections
|
||||
@@ -16,16 +17,16 @@ namespace MediaBrowser.Controller.Collections
|
||||
/// Adds to collection.
|
||||
/// </summary>
|
||||
/// <param name="collectionId">The collection identifier.</param>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <param name="itemIds">The item ids.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task AddToCollection(Guid collectionId, Guid itemId);
|
||||
Task AddToCollection(Guid collectionId, IEnumerable<Guid> itemIds);
|
||||
|
||||
/// <summary>
|
||||
/// Removes from collection.
|
||||
/// </summary>
|
||||
/// <param name="collectionId">The collection identifier.</param>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <param name="itemIds">The item ids.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task RemoveFromCollection(Guid collectionId, Guid itemId);
|
||||
Task RemoveFromCollection(Guid collectionId, IEnumerable<Guid> itemIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,15 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public virtual bool IsHidden
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public virtual bool IsOwnedItem
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
/// <summary>
|
||||
@@ -8,18 +7,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public abstract class BasePluginFolder : Folder, ICollectionFolder, IByReferenceItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the location.
|
||||
/// </summary>
|
||||
/// <value>The type of the location.</value>
|
||||
public override LocationType LocationType
|
||||
{
|
||||
get
|
||||
{
|
||||
return LocationType.Virtual;
|
||||
}
|
||||
}
|
||||
|
||||
protected BasePluginFolder()
|
||||
{
|
||||
DisplayMediaType = "CollectionFolder";
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
[IgnoreDataMember]
|
||||
public IEnumerable<BaseItem> Children
|
||||
{
|
||||
get { return ActualChildren; }
|
||||
get { return ActualChildren.Where(i => !i.IsHidden); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -905,13 +905,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <returns>BaseItem.</returns>
|
||||
private BaseItem GetLinkedChild(LinkedChild info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(info.Path))
|
||||
{
|
||||
throw new ArgumentException("Encountered linked child with empty path.");
|
||||
}
|
||||
|
||||
BaseItem item = null;
|
||||
|
||||
// First get using the cached Id
|
||||
if (info.ItemId.HasValue)
|
||||
{
|
||||
@@ -920,20 +913,19 @@ namespace MediaBrowser.Controller.Entities
|
||||
return null;
|
||||
}
|
||||
|
||||
item = LibraryManager.GetItemById(info.ItemId.Value);
|
||||
var itemById = LibraryManager.GetItemById(info.ItemId.Value);
|
||||
|
||||
if (itemById != null)
|
||||
{
|
||||
return itemById;
|
||||
}
|
||||
}
|
||||
|
||||
// If still null, search by path
|
||||
if (item == null)
|
||||
{
|
||||
item = LibraryManager.RootFolder.FindByPath(info.Path);
|
||||
}
|
||||
var item = FindLinkedChild(info);
|
||||
|
||||
// If still null, log
|
||||
if (item == null)
|
||||
{
|
||||
Logger.Warn("Unable to find linked item at {0}", info.Path);
|
||||
|
||||
// Don't keep searching over and over
|
||||
info.ItemId = Guid.Empty;
|
||||
}
|
||||
@@ -946,6 +938,43 @@ namespace MediaBrowser.Controller.Entities
|
||||
return item;
|
||||
}
|
||||
|
||||
private BaseItem FindLinkedChild(LinkedChild info)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(info.Path))
|
||||
{
|
||||
var itemByPath = LibraryManager.RootFolder.FindByPath(info.Path);
|
||||
|
||||
if (itemByPath == null)
|
||||
{
|
||||
Logger.Warn("Unable to find linked item at path {0}", info.Path);
|
||||
}
|
||||
|
||||
return itemByPath;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(info.ItemName) && !string.IsNullOrWhiteSpace(info.ItemType))
|
||||
{
|
||||
return LibraryManager.RootFolder.RecursiveChildren.FirstOrDefault(i =>
|
||||
{
|
||||
if (string.Equals(i.Name, info.ItemName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (string.Equals(i.GetType().Name, info.ItemType, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (info.ItemYear.HasValue)
|
||||
{
|
||||
return info.ItemYear.Value == (i.ProductionYear ?? -1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
|
||||
{
|
||||
var changesFound = false;
|
||||
@@ -1106,5 +1135,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
return GetRecursiveChildren(user).Where(i => !i.IsFolder && i.LocationType != LocationType.Virtual)
|
||||
.All(i => i.IsUnplayed(user));
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetHiddenChildren()
|
||||
{
|
||||
return ActualChildren.Where(i => i.IsHidden);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
public string Path { get; set; }
|
||||
public LinkedChildType Type { get; set; }
|
||||
|
||||
public string ItemName { get; set; }
|
||||
public string ItemType { get; set; }
|
||||
public int? ItemYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Serves as a cache
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user