Skip to content

Commit

Permalink
fix: characters sort by relation
Browse files Browse the repository at this point in the history
  • Loading branch information
chu-shen authored and kookxiang committed Oct 6, 2024
1 parent 3a12126 commit 045e2d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Jellyfin.Plugin.Bangumi/BangumiApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ bool SeriesSequelUnqualified(Subject subject)

public async Task<List<PersonInfo>> GetSubjectCharacters(int id, CancellationToken token)
{
var result = new List<PersonInfo>();
var characters = await SendRequest<List<RelatedCharacter>>($"{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<PersonInfo>();
}

public async Task<List<RelatedPerson>?> GetSubjectPersons(int id, CancellationToken token)
Expand Down

0 comments on commit 045e2d5

Please sign in to comment.