diff --git a/Emby.Plugin.Bangumi/ExternalIdProvider/MovieProvider.cs b/Emby.Plugin.Bangumi/ExternalIdProvider/MovieProvider.cs index ef53c24..3bcdeb5 100644 --- a/Emby.Plugin.Bangumi/ExternalIdProvider/MovieProvider.cs +++ b/Emby.Plugin.Bangumi/ExternalIdProvider/MovieProvider.cs @@ -56,7 +56,8 @@ public async Task> GetMetadata(MovieInfo info, Cancellatio result.Item.Name = subject.Name; result.Item.OriginalTitle = subject.OriginalName; result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.SetTags(subject.PopularTags); + result.Item.SetGenres(subject.GenreTags); if (DateTime.TryParse(subject.AirDate, out var airDate)) result.Item.PremiereDate = airDate; diff --git a/Emby.Plugin.Bangumi/ExternalIdProvider/SeasonProvider.cs b/Emby.Plugin.Bangumi/ExternalIdProvider/SeasonProvider.cs index 8775846..453f708 100644 --- a/Emby.Plugin.Bangumi/ExternalIdProvider/SeasonProvider.cs +++ b/Emby.Plugin.Bangumi/ExternalIdProvider/SeasonProvider.cs @@ -55,7 +55,8 @@ public async Task> GetMetadata(SeasonInfo info, Cancellat } result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.SetTags(subject.PopularTags); + result.Item.SetGenres(subject.GenreTags); if (DateTime.TryParse(subject.AirDate, out var airDate)) { diff --git a/Emby.Plugin.Bangumi/ExternalIdProvider/SeriesProvider.cs b/Emby.Plugin.Bangumi/ExternalIdProvider/SeriesProvider.cs index 0921022..421a583 100644 --- a/Emby.Plugin.Bangumi/ExternalIdProvider/SeriesProvider.cs +++ b/Emby.Plugin.Bangumi/ExternalIdProvider/SeriesProvider.cs @@ -54,7 +54,8 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat result.Item.Name = subject.Name; result.Item.OriginalTitle = subject.OriginalName; result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.SetTags(subject.PopularTags); + result.Item.SetGenres(subject.GenreTags); if (DateTime.TryParse(subject.AirDate, out var airDate)) { diff --git a/Jellyfin.Plugin.Bangumi/BangumiApi.cs b/Jellyfin.Plugin.Bangumi/BangumiApi.cs index 3de65a7..1522d4c 100644 --- a/Jellyfin.Plugin.Bangumi/BangumiApi.cs +++ b/Jellyfin.Plugin.Bangumi/BangumiApi.cs @@ -183,8 +183,8 @@ bool SeriesSequelUnqualified(Subject subject) { return subject.Platform == SubjectPlatform.Movie || subject.Platform == SubjectPlatform.OVA - || subject.Tags.Contains("OVA") - || subject.Tags.Contains("剧场版"); + || subject.GenreTags.Contains("OVA") + || subject.GenreTags.Contains("剧场版"); } var requestCount = 0; diff --git a/Jellyfin.Plugin.Bangumi/Model/Subject.cs b/Jellyfin.Plugin.Bangumi/Model/Subject.cs index 3638418..003a7bf 100644 --- a/Jellyfin.Plugin.Bangumi/Model/Subject.cs +++ b/Jellyfin.Plugin.Bangumi/Model/Subject.cs @@ -79,14 +79,19 @@ public class Subject public string? Platform { get; set; } [JsonIgnore] - public string[] Tags - { - get - { - var baseline = AllTags.Sum(tag => tag.Count) / 100; - return AllTags.Where(tag => tag.Count >= baseline).Select(tag => tag.Name).Intersect(Tag.GetCommonTagList(Type)).ToArray(); - } - } + public string[] PopularTags => AllTags + .OrderByDescending(tag => tag.Count) + .Select(tag => tag.Name) + .Take(Math.Max(8, AllTags.Count / 25)) + .ToArray(); + + [JsonIgnore] + public string[] GenreTags => AllTags + .Where(tag => Tag.GetCommonTagList(Type).Contains(tag.Name)) + .OrderByDescending(tag => tag.Count) + .Select(tag => tag.Name) + .Take(4) + .ToArray(); [JsonPropertyName("infobox")] public JsonElement? JsonInfoBox diff --git a/Jellyfin.Plugin.Bangumi/Providers/AlbumProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/AlbumProvider.cs index c2e80d0..38a4d6e 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/AlbumProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/AlbumProvider.cs @@ -82,7 +82,8 @@ public async Task> GetMetadata(AlbumInfo info, Cancel result.Item.Name = subject.Name; result.Item.OriginalTitle = subject.OriginalName; result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.Tags = subject.PopularTags; + result.Item.Genres = subject.GenreTags; if (DateTime.TryParse(subject.AirDate, out var airDate)) { diff --git a/Jellyfin.Plugin.Bangumi/Providers/BookProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/BookProvider.cs index b48a739..ec54b43 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/BookProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/BookProvider.cs @@ -40,7 +40,8 @@ public async Task> GetMetadata(BookInfo info, CancellationT result.Item.Name = subject.Name; result.Item.OriginalTitle = subject.OriginalName; result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.Tags = subject.PopularTags; + result.Item.Genres = subject.GenreTags; if (DateTime.TryParse(subject.AirDate, out var airDate)) { diff --git a/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs index 2c1c665..dd6ad0b 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs @@ -81,7 +81,8 @@ public async Task> GetMetadata(MovieInfo info, Cancellatio result.Item.Name = subject.Name; result.Item.OriginalTitle = subject.OriginalName; result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.Tags = subject.PopularTags; + result.Item.Genres = subject.GenreTags; result.Item.HomePageUrl = subject.OfficialWebSite; result.Item.EndDate = subject.EndDate; diff --git a/Jellyfin.Plugin.Bangumi/Providers/SeasonProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/SeasonProvider.cs index 6c79bd1..3db066d 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/SeasonProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/SeasonProvider.cs @@ -98,7 +98,8 @@ public async Task> GetMetadata(SeasonInfo info, Cancellat } result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.Tags = subject.PopularTags; + result.Item.Genres = subject.GenreTags; if (DateTime.TryParse(subject.AirDate, out var airDate)) { diff --git a/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs index d2ca02f..d8cf3fd 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs @@ -28,7 +28,7 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat var baseName = Path.GetFileName(info.Path); var result = new MetadataResult { - ResultLanguage = Constants.Language + ResultLanguage = info.MetadataLanguage ?? Constants.Language }; var localConfiguration = await LocalConfiguration.ForPath(info.Path); @@ -98,7 +98,8 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat result.Item.Name = subject.Name; result.Item.OriginalTitle = subject.OriginalName; result.Item.Overview = string.IsNullOrEmpty(subject.Summary) ? null : subject.Summary; - result.Item.Tags = subject.Tags; + result.Item.Tags = subject.PopularTags; + result.Item.Genres = subject.GenreTags; result.Item.HomePageUrl = subject.OfficialWebSite; result.Item.EndDate = subject.EndDate;