From 78b0f03e946f93c8f1dad37c5c5626e82e07a51e Mon Sep 17 00:00:00 2001 From: Sergey Samsonov <47633867+Weegley@users.noreply.github.com> Date: Wed, 22 Jul 2026 18:40:16 +0300 Subject: [PATCH] Skip staff entries without names (#71) ## Summary Skip Kinopoisk staff entries that do not contain either a Russian or English name. Jellyfin rejects `PersonInfo` objects with an empty `Name`, which currently causes metadata refreshes to fail with: `The value cannot be an empty string. (Parameter 'person.Name')` ## Changes - Filter out staff entries with empty or whitespace-only names. - Keep valid Russian and English fallback names. - Preserve person sort order after filtering. - Add a regression test. ## Testing - All 13 automated tests pass. --- .../ApiModelExtensionsTests.cs | 46 +++++++++++++++++++ .../ApiModelExtensions.cs | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/Jellyfin.Plugin.Kinopoisk.Tests/ApiModelExtensionsTests.cs diff --git a/src/Jellyfin.Plugin.Kinopoisk.Tests/ApiModelExtensionsTests.cs b/src/Jellyfin.Plugin.Kinopoisk.Tests/ApiModelExtensionsTests.cs new file mode 100644 index 0000000..493a1ca --- /dev/null +++ b/src/Jellyfin.Plugin.Kinopoisk.Tests/ApiModelExtensionsTests.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using System.Linq; +using KinopoiskUnofficialInfo.ApiClient; +using Xunit; + +namespace Jellyfin.Plugin.Kinopoisk.Tests +{ + public class ApiModelExtensionsTests + { + [Fact] + public void ToPersonInfosShouldSkipPersonsWithoutNames() + { + var staff = new List + { + CreateStaff(1, "Иван Иванов", string.Empty), + CreateStaff(2, string.Empty, string.Empty), + CreateStaff(3, " ", " "), + CreateStaff(4, string.Empty, "John Smith") + }; + + var result = staff.ToPersonInfos().ToArray(); + + Assert.Equal(2, result.Length); + Assert.Equal("Иван Иванов", result[0].Name); + Assert.Equal(1, result[0].SortOrder); + Assert.Equal("John Smith", result[1].Name); + Assert.Equal(2, result[1].SortOrder); + } + + private static StaffResponse CreateStaff( + int id, + string nameRu, + string nameEn) + { + return new StaffResponse + { + StaffId = id, + NameRu = nameRu, + NameEn = nameEn, + PosterUrl = string.Empty, + ProfessionText = "Актёр", + ProfessionKey = StaffResponseProfessionKey.ACTOR + }; + } + } +} diff --git a/src/Jellyfin.Plugin.Kinopoisk/ApiModelExtensions.cs b/src/Jellyfin.Plugin.Kinopoisk/ApiModelExtensions.cs index b28c83b..132b4fc 100644 --- a/src/Jellyfin.Plugin.Kinopoisk/ApiModelExtensions.cs +++ b/src/Jellyfin.Plugin.Kinopoisk/ApiModelExtensions.cs @@ -257,7 +257,7 @@ namespace Jellyfin.Plugin.Kinopoisk public static IEnumerable ToPersonInfos(this ICollection src) { var res = src.Select(s => s.ToPersonInfo()) - .Where(s => s != null) + .Where(s => s != null && !string.IsNullOrWhiteSpace(s.Name)) .ToArray(); var i = 0;