aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authormartimarkov <martimarkov@users.noreply.github.com>2026-10-26 18:12:19 -0400
committerCody Robibero <cody@robibe.ro>2026-10-26 18:12:19 -0400
commit586a81af64a18fd443d85a80a52c4e894b186f26 (patch)
treebf0fa65cdf388e8405a13074c51170bcfb2994a3 /MediaBrowser.Controller
parented211765c2ebbb3f5093f67596c267058c6a4124 (diff)
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 <cody@robibe.ro> Backported-by: Cody Robibero <cody@robibe.ro>
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs41
1 files changed, 37 insertions, 4 deletions
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
/// </summary>
/// <value>The LUFS Value.</value>
[JsonIgnore]
- public float? LUFS { get; set; }
+ public float? LUFS
+ {
+ get => _lufs;
+ set => _lufs = FiniteOrNull(value);
+ }
/// <summary>
/// Gets or sets the gain required for audio normalization.
/// </summary>
/// <value>The gain required for audio normalization.</value>
[JsonIgnore]
- public float? NormalizationGain { get; set; }
+ public float? NormalizationGain
+ {
+ get => _normalizationGain;
+ set => _normalizationGain = FiniteOrNull(value);
+ }
/// <summary>
/// Gets or sets the channel identifier.
@@ -610,7 +626,11 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The critic rating.</value>
[JsonIgnore]
- public float? CriticRating { get; set; }
+ public float? CriticRating
+ {
+ get => _criticRating;
+ set => _criticRating = FiniteOrNull(value);
+ }
/// <summary>
/// Gets or sets the custom rating.
@@ -662,7 +682,11 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The community rating.</value>
[JsonIgnore]
- public float? CommunityRating { get; set; }
+ public float? CommunityRating
+ {
+ get => _communityRating;
+ set => _communityRating = FiniteOrNull(value);
+ }
/// <summary>
/// Gets or sets the run time ticks.
@@ -1376,6 +1400,15 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="value">The value to check.</param>
+ /// <returns><paramref name="value"/> when it is finite or has no value, otherwise <see langword="null"/>.</returns>
+ private static float? FiniteOrNull(float? value)
+ => value.HasValue && !float.IsFinite(value.Value) ? null : value;
+
+ /// <summary>
/// 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
/// than two file-based sources, since there is nothing to differentiate.