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.
This commit is contained in:
MrTimscampi 2021-07-05 03:52:46 +02:00
parent 534e088105
commit ba609aefea
1 changed files with 2 additions and 1 deletions

View File

@ -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();
}