mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-13 12:16:49 +01:00
Merge pull request #16466 from PERSONALPANCHIWIRIS/fix/issue#16308_community_rating_not_updating
Fix #16308: Community ratings not updating after changing .nfo file.
This commit is contained in:
@@ -542,6 +542,16 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||
break;
|
||||
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":
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<movie>
|
||||
<title>Test Movie</title>
|
||||
<communityrating>7.5</communityrating>
|
||||
</movie>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<movie>
|
||||
<title>Test Movie</title>
|
||||
<communityrating>7,5</communityrating>
|
||||
</movie>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<movie>
|
||||
<title>Test Movie</title>
|
||||
<communityrating>15.5</communityrating>
|
||||
</movie>
|
||||
Reference in New Issue
Block a user