diff --git a/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs b/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs index 68e40a7..e848417 100644 --- a/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs +++ b/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs @@ -77,16 +77,7 @@ private MetadataSpecification[] GetMetadataSpecifications() if (SupportedMetadataFormats is not null && SupportedMetadataFormats.Any()) { - var meta = AudioFormat?.ContainerId switch - { - AudioDataIOFactory.CID_MP4 => MetadataSpecification.Mp4, - AudioDataIOFactory.CID_AIFF => MetadataSpecification.Aiff, - AudioDataIOFactory.CID_FLAC => MetadataSpecification.Vorbis, - AudioDataIOFactory.CID_OGG => MetadataSpecification.Vorbis, - AudioDataIOFactory.CID_WMA => MetadataSpecification.WindowsMediaAsf, - _ => GetFirstSupportedMeta() - }; - + var meta = ContainerIdToMetadataSpecification(AudioFormat?.ContainerId ?? 0); if (meta != MetadataSpecification.Undefined) { return new[] { meta }; @@ -95,8 +86,16 @@ private MetadataSpecification[] GetMetadataSpecifications() return Array.Empty(); } - - + + private MetadataSpecification ContainerIdToMetadataSpecification(int containerId) => containerId switch + { + AudioDataIOFactory.CID_MP4 => MetadataSpecification.Mp4, + AudioDataIOFactory.CID_AIFF => MetadataSpecification.Aiff, + AudioDataIOFactory.CID_FLAC => MetadataSpecification.Vorbis, + AudioDataIOFactory.CID_OGG => MetadataSpecification.Vorbis, + AudioDataIOFactory.CID_WMA => MetadataSpecification.WindowsMediaAsf, + _ => GetFirstSupportedMeta() + }; private MetadataSpecification GetFirstSupportedMeta() { @@ -139,19 +138,26 @@ protected override string GetFirstValuedKey(string key = "") return ""; } - - private static MetadataSpecification AtlFileFormatToMetadataFormat(Format format) => format.Name switch + private MetadataSpecification AtlFileFormatToMetadataFormat(Format format) { - "Native / MPEG-4" => MetadataSpecification.Mp4, - "Native / AIFF" => MetadataSpecification.Aiff, - "Native / Vorbis (OGG)" => MetadataSpecification.Vorbis, - "ID3v1.1" => MetadataSpecification.Id3V1, - "ID3v2.3" => MetadataSpecification.Id3V23, - "ID3v2.4" => MetadataSpecification.Id3V24, - "APEtag v2" => MetadataSpecification.Ape, - _ => MetadataSpecification.Undefined - }; - + // native formats + if (format.ShortName == "Native") + { + return ContainerIdToMetadataSpecification(AudioFormat.ContainerId); + } + + return format.Name switch + { + "Native tagging / MPEG-4" => MetadataSpecification.Mp4, + "Native tagging / AIFF" => MetadataSpecification.Aiff, + "Native tagging / Vorbis (OGG)" => MetadataSpecification.Vorbis, + "ID3v1.1" => MetadataSpecification.Id3V1, + "ID3v2.3" => MetadataSpecification.Id3V23, + "ID3v2.4" => MetadataSpecification.Id3V24, + "APEtag v2" => MetadataSpecification.Ape, + _ => MetadataSpecification.Undefined + }; + } protected static string MapAdditionalFieldKey(MetadataSpecification format, string key) => format switch {