From 6066e226c6a4d7b5dfd4669d6a3a08f420495b03 Mon Sep 17 00:00:00 2001 From: Grigory Chudov Date: Tue, 26 Mar 2013 23:13:40 -0400 Subject: [PATCH] Don't crash when trying to write AR tags to WMA file --- CUETools.Processor/Tagging.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/CUETools.Processor/Tagging.cs b/CUETools.Processor/Tagging.cs index 1352934..a388545 100644 --- a/CUETools.Processor/Tagging.cs +++ b/CUETools.Processor/Tagging.cs @@ -38,9 +38,20 @@ namespace CUETools.Processor } 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); - foreach (string tag in tags.AllKeys) - ape.SetValue(XiphTagNameToApe(tag), tags.GetValues(tag)); + if (ape != null) + { + foreach (string tag in tags.AllKeys) + ape.SetValue(XiphTagNameToApe(tag), tags.GetValues(tag)); + } return true; } @@ -112,6 +123,13 @@ namespace CUETools.Processor return tag; } + public static bool IsKnownXiphTag(string tag) + { + return tag.ToUpper() == "DATE" || + tag.ToUpper() == "TRACKNUMBER" || + tag.ToUpper() == "DISCNUMBER"; + } + public static string XiphTagNameToApe(string tag) { if (tag.ToUpper() == "DATE")