Id3 icon indicating copy to clipboard operation
Id3 copied to clipboard

TRCK Parsing

Open spottedmahn opened this issue 5 years ago • 0 comments

I have some songs, from Amazon.com, that have a frame value of new byte[] { 0, 50, 47, 49, 53, 0 } for the TRCK frame and this library isn't recognizing the values.

foobar2000 doesn't have any issues parsing it though.

I've removed the beginning, ^, and end of line, $, anchors and now it parses the values.

[Fact]
public void TRCK_BugTest()
{
	//arrange
	var path = $@"{dirStart}\01-02- DNA [Explicit] - Copy.mp3";
	var mp3 = new Mp3(path, Mp3Permissions.ReadWrite);
	var tag = mp3.GetTag(Id3TagFamily.Version2X);
	//works after changing regex
	//removing start and end things
	//data that doesn't currently work:
	//var data = new byte[] { 0, 50, 47, 49, 53, 0 };
	//was
	//Regex TrackPattern = new Regex(@"^(\d+)(?:/(\d+))?$");
	//now
	//Regex TrackPattern = new Regex(@"(\d+)(?:/(\d+))?");
	Assert.Equal(2, tag.Track.Value);
	Assert.Equal(15, tag.Track.TrackCount);

	//act 
	//should throw an exception that data will be lost
	var newMp3 = new Mp3(path + " - trck test.mp3", Mp3Permissions.ReadWrite);
	newMp3.WriteTag(tag);
	newMp3.Dispose();

	//assert
	var newMp3Assert = new Mp3(path + " - trck test.mp3", Mp3Permissions.Read);
	var tagAssert = newMp3Assert.GetTag(Id3TagFamily.Version2X);
	Assert.Equal(tag.Track.TrackCount, tagAssert.Track.TrackCount);
	Assert.Equal(tag.Track.Value, tagAssert.Track.Value);
}

Thoughts? 💭

spottedmahn avatar Dec 17 '19 05:12 spottedmahn