aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Ernesto Planas Pestana <francisco.ernesto.planas.pestana@tecnico.ulisboa.pt>2026-03-25 14:07:53 +0000
committerFrancisco Ernesto Planas Pestana <francisco.ernesto.planas.pestana@tecnico.ulisboa.pt>2026-03-25 14:07:53 +0000
commite065015d6daf39b9f4a95c7783f3af9cde56d69e (patch)
tree7bdfbda541cffccfc253ba57e187a6210dafc26c
parentdbc42bb8e236f9ead33ddd47d500b7d00f52805d (diff)
Fix #16308: Community ratings not updating after changing .nfo file.
When "replace all metadata" was issued on a film, with the Web metadata scrapers and "save to local metadata" disabled, after changing the .nfo file, 'Community rating' was not updated in the server, remaining the cached value. Fixed by changing the flag on the 'MergeData' call (line 809 - MetadataService.cs) to use the option defined by the user and not the erroneous absolute 'false' value. Also, in the .nfo parser an option for 'communityrating' was added along with value conformity verifiers. Validation tests were added.
-rw-r--r--MediaBrowser.Providers/Manager/MetadataService.cs2
-rw-r--r--MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs10
-rw-r--r--tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs43
-rw-r--r--tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating.nfo5
-rw-r--r--tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_Comma.nfo5
-rw-r--r--tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_OutOfRange.nfo5
6 files changed, 69 insertions, 1 deletions
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index e9cb46eab5..d48b525a40 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -806,7 +806,7 @@ namespace MediaBrowser.Providers.Manager
refreshResult.UpdateType |= ItemUpdateType.ImageUpdate;
}
- MergeData(localItem, temp, [], false, true);
+ MergeData(localItem, temp, [], options.ReplaceAllMetadata, true);
refreshResult.UpdateType |= ItemUpdateType.MetadataImport;
break;
diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
index 3f83f1d829..d3f0bfb5d4 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
@@ -543,6 +543,16 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "ratings":
FetchFromRatingsNode(reader, item);
break;
+ // For NFO files that have a separate community rating tag instead of using the ratings node with a name, or standard rating tag
+ case "communityrating":
+ var communityRatingText = reader.ReadElementContentAsString().Replace(',', '.');
+ if (float.TryParse(communityRatingText, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var communityRatingValue)
+ && communityRatingValue >= 0 && communityRatingValue <= 10)
+ {
+ item.CommunityRating = communityRatingValue;
+ }
+
+ break;
case "aired":
case "formed":
case "premiered":
diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs
index 1e8652f4b9..4142831c31 100644
--- a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs
+++ b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs
@@ -294,5 +294,48 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
// Verify that the lowercase "tmdbcol" is NOT in the provider IDs
Assert.False(item.ProviderIds.ContainsKey("tmdbcol"));
}
+
+ [Fact]
+ public void Parse_CommunityRating_ValidRating_Success()
+ {
+ var result = new MetadataResult<Video>()
+ {
+ Item = new Movie()
+ };
+
+ _parser.Fetch(result, "Test Data/CommunityRating.nfo", CancellationToken.None);
+ var item = (Movie)result.Item;
+
+ Assert.Equal(7.5f, item.CommunityRating);
+ }
+
+ [Fact]
+ public void Parse_CommunityRating_OutOfRange_Ignored()
+ {
+ var result = new MetadataResult<Video>()
+ {
+ Item = new Movie()
+ };
+
+ _parser.Fetch(result, "Test Data/CommunityRating_OutOfRange.nfo", CancellationToken.None);
+ var item = (Movie)result.Item;
+
+ // Rating should not be set if outside 0-10 range
+ Assert.Null(item.CommunityRating);
+ }
+
+ [Fact]
+ public void Parse_CommunityRating_Comma()
+ {
+ var result = new MetadataResult<Video>()
+ {
+ Item = new Movie()
+ };
+
+ _parser.Fetch(result, "Test Data/CommunityRating_Comma.nfo", CancellationToken.None);
+ var item = (Movie)result.Item;
+
+ Assert.Equal(7.5f, item.CommunityRating);
+ }
}
}
diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating.nfo b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating.nfo
new file mode 100644
index 0000000000..387de10c0e
--- /dev/null
+++ b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating.nfo
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<movie>
+ <title>Test Movie</title>
+ <communityrating>7.5</communityrating>
+</movie> \ No newline at end of file
diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_Comma.nfo b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_Comma.nfo
new file mode 100644
index 0000000000..4ec215e2e1
--- /dev/null
+++ b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_Comma.nfo
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<movie>
+ <title>Test Movie</title>
+ <communityrating>7,5</communityrating>
+</movie> \ No newline at end of file
diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_OutOfRange.nfo b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_OutOfRange.nfo
new file mode 100644
index 0000000000..126854edd3
--- /dev/null
+++ b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/CommunityRating_OutOfRange.nfo
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<movie>
+ <title>Test Movie</title>
+ <communityrating>15.5</communityrating>
+</movie> \ No newline at end of file