mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Misc tag handling
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using TagLib.Asf;
|
||||||
|
|
||||||
namespace CUETools.Processor
|
namespace CUETools.Processor
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,6 @@ namespace CUETools.Processor
|
|||||||
{
|
{
|
||||||
var asf = (TagLib.Asf.Tag)fileInfo.GetTag(TagLib.TagTypes.Asf, true);
|
var asf = (TagLib.Asf.Tag)fileInfo.GetTag(TagLib.TagTypes.Asf, true);
|
||||||
foreach (string tag in tags.AllKeys)
|
foreach (string tag in tags.AllKeys)
|
||||||
if (!IsKnownXiphTag(tag))
|
|
||||||
asf.SetDescriptorStrings(tags.GetValues(tag), "foobar2000/" + tag);
|
asf.SetDescriptorStrings(tags.GetValues(tag), "foobar2000/" + tag);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ namespace CUETools.Processor
|
|||||||
if (ape != null)
|
if (ape != null)
|
||||||
{
|
{
|
||||||
foreach (string tag in tags.AllKeys)
|
foreach (string tag in tags.AllKeys)
|
||||||
ape.SetValue(XiphTagNameToApe(tag), tags.GetValues(tag));
|
ape.SetValue(tag, tags.GetValues(tag));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -112,15 +112,11 @@ namespace CUETools.Processor
|
|||||||
null; // TODO: merge them?
|
null; // TODO: merge them?
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ApeTagNameToXiph(string tag)
|
public static bool IsKnownApeTag(string tag)
|
||||||
{
|
{
|
||||||
if (tag.ToUpper() == "YEAR")
|
return tag.ToUpper() == "YEAR" ||
|
||||||
return "DATE";
|
tag.ToUpper() == "TRACK" ||
|
||||||
if (tag.ToUpper() == "TRACK")
|
tag.ToUpper() == "DISC";
|
||||||
return "TRACKNUMBER";
|
|
||||||
if (tag.ToUpper() == "DISC")
|
|
||||||
return "DISCNUMBER";
|
|
||||||
return tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsKnownXiphTag(string tag)
|
public static bool IsKnownXiphTag(string tag)
|
||||||
@@ -130,17 +126,6 @@ namespace CUETools.Processor
|
|||||||
tag.ToUpper() == "DISCNUMBER";
|
tag.ToUpper() == "DISCNUMBER";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string XiphTagNameToApe(string tag)
|
|
||||||
{
|
|
||||||
if (tag.ToUpper() == "DATE")
|
|
||||||
return "Year";
|
|
||||||
if (tag.ToUpper() == "TRACKNUMBER")
|
|
||||||
return "Track";
|
|
||||||
if (tag.ToUpper() == "DISCNUMBER")
|
|
||||||
return "Disc";
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NameValueCollection Analyze(string path)
|
public static NameValueCollection Analyze(string path)
|
||||||
{
|
{
|
||||||
return Analyze(new TagLib.File.LocalFileAbstraction(path));
|
return Analyze(new TagLib.File.LocalFileAbstraction(path));
|
||||||
@@ -155,20 +140,29 @@ namespace CUETools.Processor
|
|||||||
{
|
{
|
||||||
NameValueCollection tags = new NameValueCollection();
|
NameValueCollection tags = new NameValueCollection();
|
||||||
|
|
||||||
TagLib.Ogg.XiphComment xiph = (TagLib.Ogg.XiphComment)fileInfo.GetTag(TagLib.TagTypes.Xiph);
|
var xiph = (TagLib.Ogg.XiphComment)fileInfo.GetTag(TagLib.TagTypes.Xiph);
|
||||||
TagLib.Ape.Tag ape = (TagLib.Ape.Tag)fileInfo.GetTag(TagLib.TagTypes.Ape);
|
var ape = (TagLib.Ape.Tag)fileInfo.GetTag(TagLib.TagTypes.Ape);
|
||||||
|
var asf = (TagLib.Asf.Tag)fileInfo.GetTag(TagLib.TagTypes.Asf);
|
||||||
|
|
||||||
if (xiph != null)
|
if (xiph != null)
|
||||||
{
|
{
|
||||||
foreach (string tag in xiph)
|
foreach (string tag in xiph)
|
||||||
foreach (string value in xiph.GetField(tag))
|
foreach (string value in xiph.GetField(tag))
|
||||||
|
if (!IsKnownXiphTag(tag))
|
||||||
tags.Add(tag, value);
|
tags.Add(tag, value);
|
||||||
}
|
}
|
||||||
else if (ape != null)
|
else if (ape != null)
|
||||||
{
|
{
|
||||||
foreach (string tag in ape)
|
foreach (string tag in ape)
|
||||||
foreach (string value in ape.GetItem(tag).ToStringArray())
|
foreach (string value in ape.GetItem(tag).ToStringArray())
|
||||||
tags.Add(ApeTagNameToXiph(tag), value);
|
if (!IsKnownApeTag(tag))
|
||||||
|
tags.Add(tag, value);
|
||||||
|
}
|
||||||
|
else if (asf != null)
|
||||||
|
{
|
||||||
|
foreach (ContentDescriptor desc in asf.ExtendedContentDescriptionObject)
|
||||||
|
if (desc != null && desc.Type == DataType.Unicode && desc.Name.StartsWith("foobar2000/"))
|
||||||
|
tags.Add(desc.Name.Substring("foobar2000/".Length), desc.ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user