From 10473a3990faacd3ef5dda9874a4b110ea4ccb00 Mon Sep 17 00:00:00 2001 From: sandreas <2050604+sandreas@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:44:04 +0100 Subject: [PATCH] Updated to atldotnet 6.7.0 - fixes files without tags and composer/copyright issue --- .../AudioMetadata/MetadataTrack.cs | 35 +++++-------------- .../Sandreas.AudioMetadata.csproj | 2 +- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs b/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs index 78bc157..ea3c028 100644 --- a/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs +++ b/Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs @@ -10,14 +10,13 @@ public class MetadataTrack : Track, IMetadata // meet IMetadata interface requirements public new string? Path => base.Path; public string? BasePath { get; set; } - public List SupportedMetas { get; set; } = new(); private readonly MetadataSpecification _manualMetadataSpecification = MetadataSpecification.Undefined; public MetadataSpecification[] MetadataSpecifications => GetMetadataSpecifications(); private MetadataSpecification[] GetMetadataSpecifications() { - var metadataFormats = MetadataFormats?.Where(f => f.ID != -1).ToList() ?? new List(); + var metadataFormats = MetadataFormats?.Where(f => f.ID > 0).ToList() ?? new List(); if(metadataFormats.Any()) { return metadataFormats @@ -31,10 +30,9 @@ private MetadataSpecification[] GetMetadataSpecifications() return new[] { _manualMetadataSpecification }; } - if (SupportedMetas.Any()) + if (SupportedMetadataFormats.Any()) { - - var meta = AudioFormat?.ID switch + var meta = AudioFormat?.ContainerId switch { AudioDataIOFactory.CID_MP4 => MetadataSpecification.Mp4, AudioDataIOFactory.CID_AIFF => MetadataSpecification.Aiff, @@ -56,22 +54,23 @@ private MetadataSpecification[] GetMetadataSpecifications() private MetadataSpecification GetFirstSupportedMeta() { var path = Path ?? string.Empty; - if (path.EndsWith(".ape") && SupportedMetas.Contains(MetaDataIOFactory.TagType.APE)) + var hasApeSupport = SupportedMetadataFormats.Any(f => f.ID == (int)MetaDataIOFactory.TagType.APE); + if (path.EndsWith(".ape") && hasApeSupport) { return MetadataSpecification.Ape; } - if (SupportedMetas.Contains(MetaDataIOFactory.TagType.ID3V2)) + if (SupportedMetadataFormats.Any(f => f.ID == (int)MetaDataIOFactory.TagType.ID3V2)) { return Settings.ID3v2_tagSubVersion == 3 ? MetadataSpecification.Id3V23 : MetadataSpecification.Id3V24; } - if (SupportedMetas.Contains(MetaDataIOFactory.TagType.ID3V1)) + if (SupportedMetadataFormats.Any(f => f.ID == (int)MetaDataIOFactory.TagType.ID3V1)) { return MetadataSpecification.Id3V1; } - if (SupportedMetas.Contains(MetaDataIOFactory.TagType.APE)) + if (hasApeSupport) { return MetadataSpecification.Ape; } @@ -85,7 +84,7 @@ public DateTime? RecordingDate set => Date = value; } - // be able to set totalDuration, if it has not been detected or its a dummy track + // be able to set totalDuration, if it has not been detected or it's a dummy track private TimeSpan? _totalDuration; public TimeSpan TotalDuration @@ -281,22 +280,6 @@ private void InitMetadataTrack() { Chapters ??= new List(); AdditionalFields ??= new Dictionary(); - - // if the file contains NO metadata, we need to determine the supportedMetas before the first write - // this piece of code may be removed after solving: https://github.com/Zeugma440/atldotnet/issues/286 - if (!string.IsNullOrEmpty(Path) && !MetadataSpecifications.Any()) - { - try - { - using var fs = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read, Settings.FileBufferSize, FileOptions.RandomAccess); - var audioData = AudioDataIOFactory.GetInstance().GetFromStream(fs); - SupportedMetas = audioData.GetSupportedMetas(); - } - catch (Exception) - { - // ignored - } - } } private static string? StringField(string? value) => value; diff --git a/Sandreas.AudioMetadata/Sandreas.AudioMetadata.csproj b/Sandreas.AudioMetadata/Sandreas.AudioMetadata.csproj index 8f3d15f..67bbbbf 100644 --- a/Sandreas.AudioMetadata/Sandreas.AudioMetadata.csproj +++ b/Sandreas.AudioMetadata/Sandreas.AudioMetadata.csproj @@ -19,7 +19,7 @@ - +