Skip to content

Commit

Permalink
feat: expose community rating on images if available in APIv3
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 15, 2024
1 parent b7f0356 commit e7b5cc2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Shoko.Server/API/v3/Models/Common/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public class Image
/// </summary>
public int? Height { get; set; }

/// <summary>
/// Community rating for the image, if available.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public Rating? CommunityRating { get; set; }

/// <summary>
/// Series info for the image, currently only set when sending a random
/// image.
Expand All @@ -97,6 +103,14 @@ public Image(IImageMetadata imageMetadata, bool? preferredOverride = null)
{
Width = tmdbImage.Width;
Height = tmdbImage.Height;
CommunityRating = new()
{
Value = (decimal)tmdbImage.UserRating,
Votes = tmdbImage.UserVotes,
MaxValue = 10,
Type = "User",
Source = "TMDB",
};
}
else if (imageMetadata is Image_Base imageBase && imageBase._width.HasValue && imageBase._height.HasValue)
{
Expand Down Expand Up @@ -152,6 +166,14 @@ public Image(int id, ImageEntityType imageEntityType, DataSourceType dataSource,
}
Width = tmdbImage.Width;
Height = tmdbImage.Height;
CommunityRating = new()
{
Value = (decimal)tmdbImage.UserRating,
Votes = tmdbImage.UserVotes,
MaxValue = 10,
Type = "User",
Source = "TMDB",
};
}
break;

Expand Down

0 comments on commit e7b5cc2

Please sign in to comment.