瀏覽代碼

Attempt to parse YYYY format dates in GetDictionaryDateTime

DateTime.TryParse doesn't properly parse year-only dates, so parsing results from FFProbe sometimes returns null (for example, some music tagged with Beets has yyyy format dates for release dates).
As a result, Jellyfin would previously no get the date from the FFProbe results.
This adds DateTime.TryParseExact with a format of 'yyyy' as a fallback, to attempt to properly parse the value, even if it's only a year.
MrTimscampi 4 年之前
父節點
當前提交
ba609aefea
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs

+ 2 - 1
MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs

@@ -63,7 +63,8 @@ namespace MediaBrowser.MediaEncoding.Probing
         public static DateTime? GetDictionaryDateTime(IReadOnlyDictionary<string, string> tags, string key)
         {
             if (tags.TryGetValue(key, out var val)
-                && DateTime.TryParse(val, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.AssumeUniversal, out var dateTime))
+                && (DateTime.TryParse(val, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.AssumeUniversal, out var dateTime) ||
+                    DateTime.TryParseExact(val, "yyyy", DateTimeFormatInfo.CurrentInfo, DateTimeStyles.AssumeUniversal, out dateTime)))
             {
                 return dateTime.ToUniversalTime();
             }