From 80df5dc984b714852987efb02700b46376452e5c Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 12 Mar 2026 01:27:11 +0900 Subject: [PATCH] add StartIndex and ParentId to person search --- Jellyfin.Api/Controllers/PersonsController.cs | 6 ++++++ .../Item/PeopleRepository.cs | 11 ++++++++++- .../Entities/InternalPeopleQuery.cs | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs index 438d054a4c..2b2afb0fe6 100644 --- a/Jellyfin.Api/Controllers/PersonsController.cs +++ b/Jellyfin.Api/Controllers/PersonsController.cs @@ -47,6 +47,7 @@ public class PersonsController : BaseJellyfinApiController /// /// Gets all persons. /// + /// Optional. All items with a lower index will be dropped from the response. /// Optional. The maximum number of records to return. /// The search term. /// Optional. Specify additional fields of information to return in the output. @@ -57,6 +58,7 @@ public class PersonsController : BaseJellyfinApiController /// Optional. The image types to include in the output. /// Optional. If specified results will be filtered to exclude those containing the specified PersonType. Allows multiple, comma-delimited. /// Optional. If specified results will be filtered to include only those containing the specified PersonType. Allows multiple, comma-delimited. + /// Optional. Specify this to localize the search to a specific library. Omit to use the root. /// Optional. If specified, person results will be filtered on items related to said persons. /// User id. /// Optional, include image information in output. @@ -65,6 +67,7 @@ public class PersonsController : BaseJellyfinApiController [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] public ActionResult> GetPersons( + [FromQuery] int? startIndex, [FromQuery] int? limit, [FromQuery] string? searchTerm, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields, @@ -75,6 +78,7 @@ public class PersonsController : BaseJellyfinApiController [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] excludePersonTypes, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes, + [FromQuery] Guid? parentId, [FromQuery] Guid? appearsInItemId, [FromQuery] Guid? userId, [FromQuery] bool? enableImages = true) @@ -96,6 +100,8 @@ public class PersonsController : BaseJellyfinApiController User = user, IsFavorite = !isFavorite.HasValue && isFavoriteInFilters ? true : isFavorite, AppearsInItemId = appearsInItemId ?? Guid.Empty, + ParentId = parentId, + StartIndex = startIndex, Limit = limit ?? 0 }); diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs index e2569241d2..ad9953d1b6 100644 --- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs +++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs @@ -62,7 +62,11 @@ public class PeopleRepository(IDbContextFactory dbProvider, I using var context = _dbProvider.CreateDbContext(); var dbQuery = TranslateQuery(context.Peoples.AsNoTracking(), context, filter).Select(e => e.Name).Distinct(); - // dbQuery = dbQuery.OrderBy(e => e.ListOrder); + if (filter.StartIndex.HasValue && filter.StartIndex > 0) + { + dbQuery = dbQuery.Skip(filter.StartIndex.Value); + } + if (filter.Limit > 0) { dbQuery = dbQuery.Take(filter.Limit); @@ -197,6 +201,11 @@ public class PeopleRepository(IDbContextFactory dbProvider, I query = query.Where(e => e.BaseItems!.Any(w => w.ItemId.Equals(filter.ItemId))); } + if (filter.ParentId != null) + { + query = query.Where(e => e.BaseItems!.Any(w => context.AncestorIds.Any(i => i.ParentItemId == filter.ParentId && i.ItemId == w.ItemId))); + } + if (!filter.AppearsInItemId.IsEmpty()) { query = query.Where(e => e.BaseItems!.Any(w => w.ItemId.Equals(filter.AppearsInItemId))); diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 203a16a668..f4b3910b0e 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -21,6 +21,8 @@ namespace MediaBrowser.Controller.Entities ExcludePersonTypes = excludePersonTypes; } + public int? StartIndex { get; set; } + /// /// Gets or sets the maximum number of items the query should return. /// @@ -28,6 +30,8 @@ namespace MediaBrowser.Controller.Entities public Guid ItemId { get; set; } + public Guid? ParentId { get; set; } + public IReadOnlyList PersonTypes { get; } public IReadOnlyList ExcludePersonTypes { get; }