mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-06 14:22:55 +01:00
Add support for filtering boxsets by parentId (#16882)
This commit is contained in:
@@ -280,10 +280,17 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
var item = _libraryManager.GetParentItem(parentId, userId);
|
var item = _libraryManager.GetParentItem(parentId, userId);
|
||||||
QueryResult<BaseItem> result;
|
QueryResult<BaseItem> result;
|
||||||
|
|
||||||
|
Guid[] boxSetLinkedChildAncestorIds = [];
|
||||||
if (includeItemTypes.Length == 1
|
if (includeItemTypes.Length == 1
|
||||||
&& includeItemTypes[0] == BaseItemKind.BoxSet
|
&& includeItemTypes[0] == BaseItemKind.BoxSet
|
||||||
&& item is not BoxSet)
|
&& item is not BoxSet)
|
||||||
{
|
{
|
||||||
|
var isBoxSetsLibrary = item is IHasCollectionType hct && hct.CollectionType == CollectionType.boxsets;
|
||||||
|
if (parentId.HasValue && item is not UserRootFolder && !isBoxSetsLibrary)
|
||||||
|
{
|
||||||
|
boxSetLinkedChildAncestorIds = [parentId.Value];
|
||||||
|
}
|
||||||
|
|
||||||
parentId = null;
|
parentId = null;
|
||||||
item = _libraryManager.GetUserRootFolder();
|
item = _libraryManager.GetUserRootFolder();
|
||||||
}
|
}
|
||||||
@@ -405,6 +412,7 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
MaxPremiereDate = maxPremiereDate?.ToUniversalTime(),
|
MaxPremiereDate = maxPremiereDate?.ToUniversalTime(),
|
||||||
AudioLanguages = audioLanguages,
|
AudioLanguages = audioLanguages,
|
||||||
SubtitleLanguages = subtitleLanguages,
|
SubtitleLanguages = subtitleLanguages,
|
||||||
|
LinkedChildAncestorIds = boxSetLinkedChildAncestorIds,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ids.Length != 0 || !string.IsNullOrWhiteSpace(searchTerm))
|
if (ids.Length != 0 || !string.IsNullOrWhiteSpace(searchTerm))
|
||||||
|
|||||||
@@ -1027,6 +1027,15 @@ public sealed partial class BaseItemRepository
|
|||||||
baseQuery = baseQuery.Where(e => e.Parents!.AsQueryable().Any(ancestorFilter));
|
baseQuery = baseQuery.Where(e => e.Parents!.AsQueryable().Any(ancestorFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.LinkedChildAncestorIds.Length > 0)
|
||||||
|
{
|
||||||
|
// Keep folder-like items (BoxSets, Playlists) whose linked children descend from any of the requested ancestor ids.
|
||||||
|
var linkedChildAncestorIds = filter.LinkedChildAncestorIds;
|
||||||
|
baseQuery = baseQuery.Where(e => context.LinkedChildren.Any(lc =>
|
||||||
|
lc.ParentId == e.Id
|
||||||
|
&& lc.Child!.Parents!.Any(a => linkedChildAncestorIds.Contains(a.ParentItemId))));
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(filter.AncestorWithPresentationUniqueKey))
|
if (!string.IsNullOrWhiteSpace(filter.AncestorWithPresentationUniqueKey))
|
||||||
{
|
{
|
||||||
baseQuery = baseQuery
|
baseQuery = baseQuery
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
AlbumArtistIds = [];
|
AlbumArtistIds = [];
|
||||||
AlbumIds = [];
|
AlbumIds = [];
|
||||||
AncestorIds = [];
|
AncestorIds = [];
|
||||||
|
LinkedChildAncestorIds = [];
|
||||||
ArtistIds = [];
|
ArtistIds = [];
|
||||||
BlockUnratedItems = [];
|
BlockUnratedItems = [];
|
||||||
BoxSetLibraryFolders = [];
|
BoxSetLibraryFolders = [];
|
||||||
@@ -265,6 +266,12 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
public Guid[] AncestorIds { get; set; }
|
public Guid[] AncestorIds { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a list of ancestor ids that the item's linked children must descend from.
|
||||||
|
/// Useful for filtering BoxSets/Playlists to only those that contain items from a specific library.
|
||||||
|
/// </summary>
|
||||||
|
public Guid[] LinkedChildAncestorIds { get; set; }
|
||||||
|
|
||||||
public Guid[] TopParentIds { get; set; }
|
public Guid[] TopParentIds { get; set; }
|
||||||
|
|
||||||
public CollectionType?[] PresetViews { get; set; }
|
public CollectionType?[] PresetViews { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user