From 40e1c5f4c6901469c1c7f3f763f83d1b38e5e979 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Fri, 6 Oct 2023 16:56:50 -0400 Subject: [PATCH] Remove logger parameter from XmlReaderExtensions.TryReadDateTime --- .../Extensions/XmlReaderExtensions.cs | 22 +++++-------------- .../Parsers/BaseItemXmlParser.cs | 2 +- .../Parsers/BaseNfoParser.cs | 4 ++-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/MediaBrowser.Controller/Extensions/XmlReaderExtensions.cs b/MediaBrowser.Controller/Extensions/XmlReaderExtensions.cs index 6be760b2f..aa097714a 100644 --- a/MediaBrowser.Controller/Extensions/XmlReaderExtensions.cs +++ b/MediaBrowser.Controller/Extensions/XmlReaderExtensions.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Xml; using Jellyfin.Data.Enums; using MediaBrowser.Controller.Entities; -using Microsoft.Extensions.Logging; namespace MediaBrowser.Controller.Extensions; @@ -43,26 +42,17 @@ public static class XmlReaderExtensions /// Parses a from the current node. /// /// The . - /// The to use on failure. /// The parsed . /// A value indicating whether the parsing succeeded. - public static bool TryReadDateTime(this XmlReader reader, ILogger logger, out DateTime value) + public static bool TryReadDateTime(this XmlReader reader, out DateTime value) { ArgumentNullException.ThrowIfNull(reader); - ArgumentNullException.ThrowIfNull(logger); - var text = reader.ReadElementContentAsString(); - if (DateTime.TryParse( - text, - CultureInfo.InvariantCulture, - DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, - out value)) - { - return true; - } - - logger.LogWarning("Invalid date: {Date}", text); - return false; + return DateTime.TryParse( + reader.ReadElementContentAsString(), + CultureInfo.InvariantCulture, + DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, + out value); } /// diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index f980c6c4a..8a870e0d9 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -130,7 +130,7 @@ namespace MediaBrowser.LocalMetadata.Parsers switch (reader.Name) { case "Added": - if (reader.TryReadDateTime(Logger, out var dateCreated)) + if (reader.TryReadDateTime(out var dateCreated)) { item.DateCreated = dateCreated; } diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 22210d869..47a127950 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -268,7 +268,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers switch (reader.Name) { case "dateadded": - if (reader.TryReadDateTime(Logger, out var dateCreated)) + if (reader.TryReadDateTime(out var dateCreated)) { item.DateCreated = dateCreated; } @@ -327,7 +327,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers break; case "lastplayed": - if (reader.TryReadDateTime(Logger, out var lastPlayed) + if (reader.TryReadDateTime(out var lastPlayed) && Guid.TryParse(nfoConfiguration.UserId, out var lastPlayedUserId)) { var user = _userManager.GetUserById(lastPlayedUserId);