Skip to content

Commit

Permalink
Fix MetadataSpecifications due to changed strings in atldotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
sandreas committed Dec 13, 2024
1 parent b194468 commit f0e1f45
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -95,8 +86,16 @@ private MetadataSpecification[] GetMetadataSpecifications()

return Array.Empty<MetadataSpecification>();
}



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()
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit f0e1f45

Please sign in to comment.