Ignore avg critic rating Rotten Tomatoes
This commit is contained in:
parent
1244502fa8
commit
7a93731992
|
@ -274,8 +274,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var added))
|
||||
{
|
||||
item.DateCreated = added;
|
||||
|
@ -284,7 +282,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
Logger.LogWarning("Invalid Added value found: {Value}", val);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -376,16 +373,14 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
case "playcount":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
if (!string.IsNullOrWhiteSpace(val) && !string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
|
||||
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out var count)
|
||||
&& Guid.TryParse(nfoConfiguration.UserId, out var guid))
|
||||
{
|
||||
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out var count))
|
||||
{
|
||||
var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
|
||||
var user = _userManager.GetUserById(guid);
|
||||
userData = _userDataManager.GetUserData(user, item);
|
||||
userData.PlayCount = count;
|
||||
_userDataManager.SaveUserData(user, item, userData, UserDataSaveReason.Import, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -393,11 +388,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
case "lastplayed":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
if (!string.IsNullOrWhiteSpace(val) && !string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
|
||||
if (Guid.TryParse(nfoConfiguration.UserId, out var guid))
|
||||
{
|
||||
if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var added))
|
||||
{
|
||||
var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
|
||||
var user = _userManager.GetUserById(guid);
|
||||
userData = _userDataManager.GetUserData(user, item);
|
||||
userData.LastPlayedDate = added;
|
||||
_userDataManager.SaveUserData(user, item, userData, UserDataSaveReason.Import, CancellationToken.None);
|
||||
|
@ -487,13 +482,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
var text = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
if (int.TryParse(text.AsSpan().LeftPart(' '), NumberStyles.Integer, CultureInfo.InvariantCulture, out var runtime))
|
||||
{
|
||||
item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -630,14 +622,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
var hasDisplayOrder = item as IHasDisplayOrder;
|
||||
if (hasDisplayOrder is not null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
if (item is IHasDisplayOrder hasDisplayOrder && !string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
hasDisplayOrder.DisplayOrder = val;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -646,13 +634,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (int.TryParse(val, out var productionYear) && productionYear > 1850)
|
||||
{
|
||||
item.ProductionYear = productionYear;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -661,14 +646,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
var rating = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(rating))
|
||||
{
|
||||
// All external meta is saving this as '.' for decimal I believe...but just to be sure
|
||||
if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var val))
|
||||
{
|
||||
item.CommunityRating = val;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -697,14 +679,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var date) && date.Year > 1850)
|
||||
{
|
||||
item.PremiereDate = date;
|
||||
item.ProductionYear = date.Year;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -715,13 +694,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var date) && date.Year > 1850)
|
||||
{
|
||||
item.EndDate = date;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1191,23 +1167,23 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
case "value":
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (float.TryParse(val, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var ratingValue))
|
||||
{
|
||||
// if ratingName contains tomato --> assume critic rating
|
||||
if (ratingName is not null &&
|
||||
ratingName.Contains("tomato", StringComparison.OrdinalIgnoreCase) &&
|
||||
!ratingName.Contains("audience", StringComparison.OrdinalIgnoreCase))
|
||||
if (ratingName is not null
|
||||
&& ratingName.Contains("tomato", StringComparison.OrdinalIgnoreCase)
|
||||
&& !ratingName.Contains("audience", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!ratingName.Contains("avg", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.CriticRating = ratingValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item.CommunityRating = ratingValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -1289,13 +1265,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intVal))
|
||||
{
|
||||
sortOrder = intVal;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user