mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-12 19:56:30 +01:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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