Don't crash when trying to write AR tags to WMA file

This commit is contained in:
Grigory Chudov
2013-03-26 23:13:40 -04:00
parent b6132b894c
commit 6066e226c6

View File

@@ -38,9 +38,20 @@ namespace CUETools.Processor
} }
return true; return true;
} }
if (fileInfo is TagLib.Asf.File)
{
var asf = (TagLib.Asf.Tag)fileInfo.GetTag(TagLib.TagTypes.Asf, true);
foreach (string tag in tags.AllKeys)
if (!IsKnownXiphTag(tag))
asf.SetDescriptorString(tag, tags.GetValues(tag));
return true;
}
TagLib.Ape.Tag ape = (TagLib.Ape.Tag)fileInfo.GetTag(TagLib.TagTypes.Ape, true); TagLib.Ape.Tag ape = (TagLib.Ape.Tag)fileInfo.GetTag(TagLib.TagTypes.Ape, true);
if (ape != null)
{
foreach (string tag in tags.AllKeys) foreach (string tag in tags.AllKeys)
ape.SetValue(XiphTagNameToApe(tag), tags.GetValues(tag)); ape.SetValue(XiphTagNameToApe(tag), tags.GetValues(tag));
}
return true; return true;
} }
@@ -112,6 +123,13 @@ namespace CUETools.Processor
return tag; return tag;
} }
public static bool IsKnownXiphTag(string tag)
{
return tag.ToUpper() == "DATE" ||
tag.ToUpper() == "TRACKNUMBER" ||
tag.ToUpper() == "DISCNUMBER";
}
public static string XiphTagNameToApe(string tag) public static string XiphTagNameToApe(string tag)
{ {
if (tag.ToUpper() == "DATE") if (tag.ToUpper() == "DATE")