From 390c79793ecbd1aecb5b56b4b31e1a4e3218da08 Mon Sep 17 00:00:00 2001 From: ta264 Date: Wed, 27 Mar 2019 22:31:15 +0000 Subject: [PATCH] Fixed: Unparsable original year in tag --- .../MediaFiles/AudioTagServiceFixture.cs | 18 +++++++++++++++++- src/NzbDrone.Core/MediaFiles/AudioTag.cs | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs index a9bd0701d..637c03afa 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs @@ -298,7 +298,23 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture onDisk.Date.HasValue.Should().BeFalse(); onDisk.OriginalReleaseDate.HasValue.Should().BeFalse(); } - + + [Test] + public void should_ignore_non_parsable_id3v23_date() + { + GivenFileCopy("nin.mp2"); + + using(var file = TagLib.File.Create(copiedFile)) + { + var id3tag = (TagLib.Id3v2.Tag) file.GetTag(TagLib.TagTypes.Id3v2); + id3tag.SetTextFrame("TORY", "0"); + file.Save(); + } + + var tag = Subject.ReadAudioTag(copiedFile); + tag.OriginalReleaseDate.HasValue.Should().BeFalse(); + } + private TrackFile GivenPopulatedTrackfile() { var meta = Builder.CreateNew().Build(); diff --git a/src/NzbDrone.Core/MediaFiles/AudioTag.cs b/src/NzbDrone.Core/MediaFiles/AudioTag.cs index d0c4c7bf9..1da33d112 100644 --- a/src/NzbDrone.Core/MediaFiles/AudioTag.cs +++ b/src/NzbDrone.Core/MediaFiles/AudioTag.cs @@ -252,7 +252,7 @@ namespace NzbDrone.Core.MediaFiles else { // taglib maps the v3 TORY to TDRC so we just get a year - return Int32.TryParse(date, out int year) ? new DateTime(year, 1, 1) : default(DateTime?); + return Int32.TryParse(date, out int year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?); } }