From 22644075e784ccd71d39a27eae6d1f7434f47a00 Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 12 Apr 2026 12:42:49 +0900 Subject: [PATCH 1/2] add NameStartsWith and NameLessThan filters to Person search --- Jellyfin.Api/Controllers/PersonsController.cs | 6 ++++++ .../Item/PeopleRepository.cs | 10 ++++++++++ .../Entities/InternalPeopleQuery.cs | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs index 2b2afb0fe6..a113ded049 100644 --- a/Jellyfin.Api/Controllers/PersonsController.cs +++ b/Jellyfin.Api/Controllers/PersonsController.cs @@ -50,6 +50,8 @@ public class PersonsController : BaseJellyfinApiController /// 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. Filter by items whose name starts with the given input string. + /// Optional. Filter by items whose name will appear before this value when sorted alphabetically. /// Optional. Specify additional fields of information to return in the output. /// Optional. Specify additional filters to apply. /// Optional filter by items that are marked as favorite, or not. userId is required. @@ -70,6 +72,8 @@ public class PersonsController : BaseJellyfinApiController [FromQuery] int? startIndex, [FromQuery] int? limit, [FromQuery] string? searchTerm, + [FromQuery] string? nameStartsWith, + [FromQuery] string? nameLessThan, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters, [FromQuery] bool? isFavorite, @@ -97,6 +101,8 @@ public class PersonsController : BaseJellyfinApiController excludePersonTypes) { NameContains = searchTerm, + NameStartsWith = nameStartsWith, + NameLessThan = nameLessThan, User = user, IsFavorite = !isFavorite.HasValue && isFavoriteInFilters ? true : isFavorite, AppearsInItemId = appearsInItemId ?? Guid.Empty, diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs index ad9953d1b6..adb5e08cf9 100644 --- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs +++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs @@ -235,6 +235,16 @@ public class PeopleRepository(IDbContextFactory dbProvider, I query = query.Where(e => e.Name.ToUpper().Contains(nameContainsUpper)); } + if (!string.IsNullOrWhiteSpace(filter.NameStartsWith)) + { + query = query.Where(e => e.Name.StartsWith(filter.NameStartsWith.ToLowerInvariant())); + } + + if (!string.IsNullOrWhiteSpace(filter.NameLessThan)) + { + query = query.Where(e => e.Name.CompareTo(filter.NameLessThan.ToLowerInvariant()) < 0); + } + return query; } diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index f4b3910b0e..373ec7ffeb 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -42,6 +42,10 @@ namespace MediaBrowser.Controller.Entities public string NameContains { get; set; } + public string NameStartsWith { get; set; } + + public string NameLessThan { get; set; } + public User User { get; set; } public bool? IsFavorite { get; set; } From bb265cd4030e966aec1afbd31eafc0973531c232 Mon Sep 17 00:00:00 2001 From: dkanada Date: Mon, 13 Apr 2026 13:50:04 +0900 Subject: [PATCH 2/2] add NameStartsWithOrGreater parameter to Persons endpoint --- Jellyfin.Api/Controllers/PersonsController.cs | 3 +++ Jellyfin.Server.Implementations/Item/PeopleRepository.cs | 5 +++++ MediaBrowser.Controller/Entities/InternalPeopleQuery.cs | 2 ++ 3 files changed, 10 insertions(+) diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs index a113ded049..1811a219ac 100644 --- a/Jellyfin.Api/Controllers/PersonsController.cs +++ b/Jellyfin.Api/Controllers/PersonsController.cs @@ -52,6 +52,7 @@ public class PersonsController : BaseJellyfinApiController /// The search term. /// Optional. Filter by items whose name starts with the given input string. /// Optional. Filter by items whose name will appear before this value when sorted alphabetically. + /// Optional. Filter by items whose name will appear after this value when sorted alphabetically. /// Optional. Specify additional fields of information to return in the output. /// Optional. Specify additional filters to apply. /// Optional filter by items that are marked as favorite, or not. userId is required. @@ -74,6 +75,7 @@ public class PersonsController : BaseJellyfinApiController [FromQuery] string? searchTerm, [FromQuery] string? nameStartsWith, [FromQuery] string? nameLessThan, + [FromQuery] string? nameStartsWithOrGreater, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields, [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters, [FromQuery] bool? isFavorite, @@ -103,6 +105,7 @@ public class PersonsController : BaseJellyfinApiController NameContains = searchTerm, NameStartsWith = nameStartsWith, NameLessThan = nameLessThan, + NameStartsWithOrGreater = nameStartsWithOrGreater, User = user, IsFavorite = !isFavorite.HasValue && isFavoriteInFilters ? true : isFavorite, AppearsInItemId = appearsInItemId ?? Guid.Empty, diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs index adb5e08cf9..7147fbfe7d 100644 --- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs +++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs @@ -245,6 +245,11 @@ public class PeopleRepository(IDbContextFactory dbProvider, I query = query.Where(e => e.Name.CompareTo(filter.NameLessThan.ToLowerInvariant()) < 0); } + if (!string.IsNullOrWhiteSpace(filter.NameStartsWithOrGreater)) + { + query = query.Where(e => e.Name.CompareTo(filter.NameStartsWithOrGreater.ToLowerInvariant()) >= 0); + } + return query; } diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 373ec7ffeb..e12ba22343 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -46,6 +46,8 @@ namespace MediaBrowser.Controller.Entities public string NameLessThan { get; set; } + public string NameStartsWithOrGreater { get; set; } + public User User { get; set; } public bool? IsFavorite { get; set; }