Fixed: Unparsable original year in tag

pull/6/head
ta264 6 years ago
parent b23e7ec513
commit 390c79793e

@ -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<ArtistMetadata>.CreateNew().Build();

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

Loading…
Cancel
Save