mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-02-18 00:17:43 +01:00
Merge pull request #1517 from Mbucari/master
Fix mp3 conversion of liberated AC-4 files and add metadata tags
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
using AAXClean.Codecs;
|
using AAXClean.Codecs;
|
||||||
using NAudio.Lame;
|
using NAudio.Lame;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace AaxDecrypter
|
namespace AaxDecrypter
|
||||||
{
|
{
|
||||||
public static class MpegUtil
|
public static class MpegUtil
|
||||||
@@ -50,20 +52,22 @@ namespace AaxDecrypter
|
|||||||
if (mp4File.AppleTags.AppleListBox.GetFreeformTagString(TagDomain, "SUBTITLE") is string subtitle)
|
if (mp4File.AppleTags.AppleListBox.GetFreeformTagString(TagDomain, "SUBTITLE") is string subtitle)
|
||||||
lameConfig.ID3.Subtitle = 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)
|
if (chapters?.Count > 0)
|
||||||
{
|
{
|
||||||
var cue = Cue.CreateContents(lameConfig.ID3.Title + ".mp3", chapters);
|
var cue = Cue.CreateContents(lameConfig.ID3.Title + ".mp3", chapters);
|
||||||
lameConfig.ID3.UserDefinedText.Add("CUESHEET", cue);
|
lameConfig.ID3.UserDefinedText.Add("CUESHEET", cue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Copy over all other freeform tags
|
||||||
|
foreach (var t in mp4File.AppleTags.AppleListBox.Tags.OfType<Mpeg4Lib.Boxes.FreeformTagBox>())
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,10 +63,6 @@ namespace FileLiberator
|
|||||||
using var m4bFileStream = File.Open(entry.m4bPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
using var m4bFileStream = File.Open(entry.m4bPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
var m4bBook = new Mp4File(m4bFileStream);
|
var m4bBook = new Mp4File(m4bFileStream);
|
||||||
|
|
||||||
//AAXClean.Codecs only supports decoding AAC and E-AC-3 audio.
|
|
||||||
if (m4bBook.AudioSampleEntry.Esds is null && m4bBook.AudioSampleEntry.Dec3 is null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
OnTitleDiscovered(m4bBook.AppleTags.Title);
|
OnTitleDiscovered(m4bBook.AppleTags.Title);
|
||||||
OnAuthorsDiscovered(m4bBook.AppleTags.FirstAuthor);
|
OnAuthorsDiscovered(m4bBook.AppleTags.FirstAuthor);
|
||||||
OnNarratorsDiscovered(m4bBook.AppleTags.Narrator);
|
OnNarratorsDiscovered(m4bBook.AppleTags.Narrator);
|
||||||
|
|||||||
@@ -254,6 +254,11 @@ namespace FileLiberator
|
|||||||
tags.Year ??= pubDate.Year.ToString();
|
tags.Year ??= pubDate.Year.ToString();
|
||||||
tags.ReleaseDate ??= pubDate.ToString("dd-MMM-yyyy");
|
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)
|
private void AaxcDownloader_RetrievedCoverArt(object? sender, byte[]? e)
|
||||||
|
|||||||
Reference in New Issue
Block a user