Skip to content

Commit

Permalink
write common tags to genres
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed Dec 25, 2024
1 parent 761e0e9 commit 5c8a8a9
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Emby.Plugin.Bangumi/ExternalIdProvider/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public async Task<MetadataResult<Movie>> 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;
Expand Down
3 changes: 2 additions & 1 deletion Emby.Plugin.Bangumi/ExternalIdProvider/SeasonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public async Task<MetadataResult<Season>> 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))
{
Expand Down
3 changes: 2 additions & 1 deletion Emby.Plugin.Bangumi/ExternalIdProvider/SeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public async Task<MetadataResult<Series>> 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))
{
Expand Down
4 changes: 2 additions & 2 deletions Jellyfin.Plugin.Bangumi/BangumiApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 13 additions & 8 deletions Jellyfin.Plugin.Bangumi/Model/Subject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Jellyfin.Plugin.Bangumi/Providers/AlbumProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public async Task<MetadataResult<MusicAlbum>> 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))
{
Expand Down
3 changes: 2 additions & 1 deletion Jellyfin.Plugin.Bangumi/Providers/BookProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public async Task<MetadataResult<Book>> 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))
{
Expand Down
3 changes: 2 additions & 1 deletion Jellyfin.Plugin.Bangumi/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public async Task<MetadataResult<Movie>> 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;

Expand Down
3 changes: 2 additions & 1 deletion Jellyfin.Plugin.Bangumi/Providers/SeasonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public async Task<MetadataResult<Season>> 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))
{
Expand Down
5 changes: 3 additions & 2 deletions Jellyfin.Plugin.Bangumi/Providers/SeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
var baseName = Path.GetFileName(info.Path);
var result = new MetadataResult<Series>
{
ResultLanguage = Constants.Language
ResultLanguage = info.MetadataLanguage ?? Constants.Language
};
var localConfiguration = await LocalConfiguration.ForPath(info.Path);

Expand Down Expand Up @@ -98,7 +98,8 @@ public async Task<MetadataResult<Series>> 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;

Expand Down

0 comments on commit 5c8a8a9

Please sign in to comment.