Skip to content

Commit b2b2110

Browse files
YodaDaCodadecriptor
authored andcommitted
feat(id3): support apple MVNM/MVIN frame
1 parent 8a45f31 commit b2b2110

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs

+48
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,54 @@ public void TestUserTextInformationFrame ()
14991499
});
15001500
}
15011501

1502+
[Test]
1503+
public void TestMovementNameFrame ()
1504+
{
1505+
ByteVector id = "MVNM";
1506+
var frame = new TextInformationFrame (id) {
1507+
Text = val_mult
1508+
};
1509+
1510+
FrameTest (frame, 2,
1511+
delegate (Frame f, StringType e) {
1512+
(f as TextInformationFrame).TextEncoding = e;
1513+
},
1514+
(d, v) => new TextInformationFrame (d, v),
1515+
1516+
delegate (Frame f, string m) {
1517+
var g = (f as TextInformationFrame);
1518+
Assert.AreEqual (id, g.FrameId, m);
1519+
Assert.AreEqual (val_mult.Length, g.Text.Length, m);
1520+
for (int i = 0; i < val_mult.Length; i++) {
1521+
Assert.AreEqual (val_mult[i], g.Text[i], m);
1522+
}
1523+
});
1524+
}
1525+
1526+
[Test]
1527+
public void TestMovementNumberFrame ()
1528+
{
1529+
ByteVector id = "MVIN";
1530+
var frame = new TextInformationFrame (id) {
1531+
Text = val_mult
1532+
};
1533+
1534+
FrameTest (frame, 2,
1535+
delegate (Frame f, StringType e) {
1536+
(f as TextInformationFrame).TextEncoding = e;
1537+
},
1538+
(d, v) => new TextInformationFrame (d, v),
1539+
1540+
delegate (Frame f, string m) {
1541+
var g = (f as TextInformationFrame);
1542+
Assert.AreEqual (id, g.FrameId, m);
1543+
Assert.AreEqual (val_mult.Length, g.Text.Length, m);
1544+
for (int i = 0; i < val_mult.Length; i++) {
1545+
Assert.AreEqual (val_mult[i], g.Text[i], m);
1546+
}
1547+
});
1548+
}
1549+
15021550
[Test]
15031551
public void TestUniqueFileIdentifierFrame ()
15041552
{

src/TaglibSharp/Id3v2/FrameFactory.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ public static Frame CreateFrame (ByteVector data, File file, ref int offset, byt
216216
if (header.FrameId == FrameType.TXXX)
217217
return new UserTextInformationFrame (data, position, header, version);
218218

219-
if (header.FrameId[0] == (byte)'T')
219+
// Apple proprietary MVNM (Movement Name), MVIN (Movement Number) are in fact text frames.
220+
if (header.FrameId[0] == (byte)'T' ||
221+
header.FrameId == "MVNM" ||
222+
header.FrameId == "MVIN")
220223
return new TextInformationFrame (data, position, header, version);
221224

222225
// Involved People List (frames 4.4 in 2.3. in 2.4 this is a TIPL frame)

src/TaglibSharp/Id3v2/FrameHeader.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static ReadOnlyByteVector ConvertId (ByteVector id, byte version, bool toVersion
381381
}
382382

383383
static readonly ReadOnlyByteVector[,] version2_frames =
384-
new ReadOnlyByteVector[59, 2] {
384+
new ReadOnlyByteVector[61, 2] {
385385
{ "BUF", "RBUF" },
386386
{ "CNT", "PCNT" },
387387
{ "COM", "COMM" },
@@ -440,7 +440,9 @@ static ReadOnlyByteVector ConvertId (ByteVector id, byte version, bool toVersion
440440
{ "WCP", "WCOP" },
441441
{ "WPB", "WPUB" },
442442
{ "WXX", "WXXX" },
443-
{ "XRV", "RVA2" }
443+
{ "XRV", "RVA2" },
444+
{ "MVN", "MVNM" },
445+
{ "MVI", "MVIN" }
444446
};
445447

446448
static readonly ReadOnlyByteVector[,] version3_frames =

src/TaglibSharp/Id3v2/FrameTypes.cs

+2
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@ static class FrameType
101101
public static readonly ReadOnlyByteVector WPUB = "WPUB";
102102
public static readonly ReadOnlyByteVector WXXX = "WXXX";
103103
public static readonly ReadOnlyByteVector ETCO = "ETCO";
104+
public static readonly ReadOnlyByteVector MVNM = "MVNM"; // Movement Name
105+
public static readonly ReadOnlyByteVector MVIN = "MVIN"; // Movement Number/Count
104106
}
105107
}

src/TaglibSharp/Id3v2/Frames/TextIdentificationFrame.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,9 @@ protected void ParseRawData ()
875875
FrameId == FrameType.TPE1 ||
876876
FrameId == FrameType.TPE2 ||
877877
FrameId == FrameType.TPE3 ||
878-
FrameId == FrameType.TPE4) {
878+
FrameId == FrameType.TPE4 ||
879+
FrameId == FrameType.MVNM ||
880+
FrameId == FrameType.MVIN) {
879881
field_list.AddRange (value.Split ('/'));
880882
} else if (FrameId == FrameType.TCON) {
881883
while (value.Length > 1 && value[0] == '(') {

0 commit comments

Comments
 (0)