From 7dfdc0688a49de4e0eb60b5774ddb6506b207d02 Mon Sep 17 00:00:00 2001 From: MBucari Date: Sat, 27 Dec 2025 15:40:57 -0700 Subject: [PATCH] Add some more useful tags AUDIBLE_ACR, AUDIBLE_DRM_TYPE, and AUDIBLE_LOCALE --- Source/AaxDecrypter/MpegUtil.cs | 22 ++++++++++++--------- Source/FileLiberator/DownloadDecryptBook.cs | 5 +++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Source/AaxDecrypter/MpegUtil.cs b/Source/AaxDecrypter/MpegUtil.cs index 84d99925..be051b34 100644 --- a/Source/AaxDecrypter/MpegUtil.cs +++ b/Source/AaxDecrypter/MpegUtil.cs @@ -2,7 +2,9 @@ using AAXClean.Codecs; using NAudio.Lame; using System; +using System.Linq; +#nullable enable namespace AaxDecrypter { public static class MpegUtil @@ -50,20 +52,22 @@ namespace AaxDecrypter if (mp4File.AppleTags.AppleListBox.GetFreeformTagString(TagDomain, "SUBTITLE") is string subtitle) lameConfig.ID3.Subtitle = subtitle; - if (mp4File.AppleTags.AppleListBox.GetFreeformTagString(TagDomain, "LANGUAGE") is string lang) - lameConfig.ID3.UserDefinedText.Add("LANGUAGE", lang); - - if (mp4File.AppleTags.AppleListBox.GetFreeformTagString(TagDomain, "SERIES") is string series) - lameConfig.ID3.UserDefinedText.Add("SERIES", series); - - if (mp4File.AppleTags.AppleListBox.GetFreeformTagString(TagDomain, "PART") is string part) - lameConfig.ID3.UserDefinedText.Add("PART", part); - if (chapters?.Count > 0) { var cue = Cue.CreateContents(lameConfig.ID3.Title + ".mp3", chapters); lameConfig.ID3.UserDefinedText.Add("CUESHEET", cue); } + + //Copy over all other freeform tags + foreach (var t in mp4File.AppleTags.AppleListBox.Tags.OfType()) + { + if (t.Name?.Name is string name && + t.Mean?.ReverseDnsDomain is string domain && + !lameConfig.ID3.UserDefinedText.ContainsKey(name) && + mp4File.AppleTags.AppleListBox.GetFreeformTagString(domain, name) is string tagStr && + !string.IsNullOrWhiteSpace(tagStr)) + lameConfig.ID3.UserDefinedText.Add(name, tagStr); + } } } } diff --git a/Source/FileLiberator/DownloadDecryptBook.cs b/Source/FileLiberator/DownloadDecryptBook.cs index 97a279bd..6797324f 100644 --- a/Source/FileLiberator/DownloadDecryptBook.cs +++ b/Source/FileLiberator/DownloadDecryptBook.cs @@ -254,6 +254,11 @@ namespace FileLiberator tags.Year ??= pubDate.Year.ToString(); tags.ReleaseDate ??= pubDate.ToString("dd-MMM-yyyy"); } + + const string tagDomain = "org.libation"; + aaxFile.AppleTags.AppleListBox.EditOrAddFreeformTag(tagDomain, "AUDIBLE_ACR", tags.Acr); + aaxFile.AppleTags.AppleListBox.EditOrAddFreeformTag(tagDomain, "AUDIBLE_DRM_TYPE", options.DrmType.ToString()); + aaxFile.AppleTags.AppleListBox.EditOrAddFreeformTag(tagDomain, "AUDIBLE_LOCALE", options.LibraryBook.Book.Locale); } private void AaxcDownloader_RetrievedCoverArt(object? sender, byte[]? e)