From 045e2d572fe9a69e14e39b5a4481a92b103e78a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=9D=E7=A5=9E?= <45256288+chu-shen@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:40:58 +0800 Subject: [PATCH] fix: characters sort by relation --- Jellyfin.Plugin.Bangumi/BangumiApi.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Plugin.Bangumi/BangumiApi.cs b/Jellyfin.Plugin.Bangumi/BangumiApi.cs index dfdbe6f..5a38d36 100644 --- a/Jellyfin.Plugin.Bangumi/BangumiApi.cs +++ b/Jellyfin.Plugin.Bangumi/BangumiApi.cs @@ -184,10 +184,12 @@ bool SeriesSequelUnqualified(Subject subject) public async Task> GetSubjectCharacters(int id, CancellationToken token) { - var result = new List(); var characters = await SendRequest>($"{BaseUrl}/v0/subjects/{id}/characters", token); - characters?.ForEach(character => result.AddRange(character.ToPersonInfos())); - return result; + + return characters? + .OrderBy(c => c.Relation == "主角" ? 0 : c.Relation == "配角" ? 1 : c.Relation == "客串" ? 2 : 3) + .SelectMany(character => character.ToPersonInfos()) + .ToList() ?? new List(); } public async Task?> GetSubjectPersons(int id, CancellationToken token)