mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Add .nfo ratings tag
This commit is contained in:
parent
7acee4070e
commit
357429b8ea
@ -624,6 +624,21 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "ratings":
|
||||||
|
{
|
||||||
|
if (!reader.IsEmptyElement)
|
||||||
|
{
|
||||||
|
using var subtree = reader.ReadSubtree();
|
||||||
|
FetchFromRatingsNode(subtree, item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "aired":
|
case "aired":
|
||||||
case "formed":
|
case "formed":
|
||||||
case "premiered":
|
case "premiered":
|
||||||
@ -866,6 +881,90 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FetchFromRatingsNode(XmlReader reader, T item)
|
||||||
|
{
|
||||||
|
reader.MoveToContent();
|
||||||
|
reader.Read();
|
||||||
|
|
||||||
|
// Loop through each element
|
||||||
|
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
||||||
|
{
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
{
|
||||||
|
switch (reader.Name)
|
||||||
|
{
|
||||||
|
case "rating":
|
||||||
|
{
|
||||||
|
if (reader.IsEmptyElement)
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ratingName = reader.GetAttribute("name");
|
||||||
|
|
||||||
|
using var subtree = reader.ReadSubtree();
|
||||||
|
FetchFromRatingNode(subtree, item, ratingName);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
reader.Skip();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FetchFromRatingNode(XmlReader reader, T item, string? ratingName)
|
||||||
|
{
|
||||||
|
reader.MoveToContent();
|
||||||
|
reader.Read();
|
||||||
|
|
||||||
|
// Loop through each element
|
||||||
|
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
||||||
|
{
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
{
|
||||||
|
switch (reader.Name)
|
||||||
|
{
|
||||||
|
case "value":
|
||||||
|
var val = reader.ReadElementContentAsString();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
|
{
|
||||||
|
if (float.TryParse(val.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var ratingValue))
|
||||||
|
{
|
||||||
|
// if ratingName contains tomato --> assume critic rating
|
||||||
|
if (ratingName != null && ratingName.Contains("tomato", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
item.CriticRating = ratingValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.CommunityRating = ratingValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reader.Skip();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the persons from XML node.
|
/// Gets the persons from XML node.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user