From 586a81af64a18fd443d85a80a52c4e894b186f26 Mon Sep 17 00:00:00 2001 From: martimarkov Date: Mon, 26 Oct 2026 18:12:19 -0400 Subject: Backport pull request #18267 from jellyfin/release-12.z Do not store ratings or gains that are not finite numbers Original-merge: 02c49f03382f35c70bb2f730e4ed7dc950239b93 Merged-by: crobibero Backported-by: Cody Robibero --- MediaBrowser.Controller/Entities/BaseItem.cs | 41 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 022f8f0fbf..a1e955f33f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -102,6 +102,14 @@ namespace MediaBrowser.Controller.Entities private string _originalLanguage; + private float? _lufs; + + private float? _normalizationGain; + + private float? _criticRating; + + private float? _communityRating; + public const char SlugChar = '-'; protected BaseItem() @@ -154,14 +162,22 @@ namespace MediaBrowser.Controller.Entities /// /// The LUFS Value. [JsonIgnore] - public float? LUFS { get; set; } + public float? LUFS + { + get => _lufs; + set => _lufs = FiniteOrNull(value); + } /// /// Gets or sets the gain required for audio normalization. /// /// The gain required for audio normalization. [JsonIgnore] - public float? NormalizationGain { get; set; } + public float? NormalizationGain + { + get => _normalizationGain; + set => _normalizationGain = FiniteOrNull(value); + } /// /// Gets or sets the channel identifier. @@ -610,7 +626,11 @@ namespace MediaBrowser.Controller.Entities /// /// The critic rating. [JsonIgnore] - public float? CriticRating { get; set; } + public float? CriticRating + { + get => _criticRating; + set => _criticRating = FiniteOrNull(value); + } /// /// Gets or sets the custom rating. @@ -662,7 +682,11 @@ namespace MediaBrowser.Controller.Entities /// /// The community rating. [JsonIgnore] - public float? CommunityRating { get; set; } + public float? CommunityRating + { + get => _communityRating; + set => _communityRating = FiniteOrNull(value); + } /// /// Gets or sets the run time ticks. @@ -1375,6 +1399,15 @@ namespace MediaBrowser.Controller.Entities return string.Join('/', terms); } + /// + /// Treats a rating or gain that is not a finite number as no value, since NaN and infinity + /// cannot be stored by every database or written as JSON. + /// + /// The value to check. + /// when it is finite or has no value, otherwise . + private static float? FiniteOrNull(float? value) + => value.HasValue && !float.IsFinite(value.Value) ? null : value; + /// /// Derives the prefix shared by the supplied media source items' file names, used to strip the /// common part and surface a short version label per source. Returns null when there are fewer -- cgit v1.2.3