Add option to strip Audible brand audio
This commit is contained in:
parent
d595b62f13
commit
9862593f4a
@ -5,8 +5,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AAXClean" Version="0.4.2" />
|
<PackageReference Include="AAXClean" Version="0.4.4" />
|
||||||
<PackageReference Include="AAXClean.Codecs" Version="0.2.0" />
|
<PackageReference Include="AAXClean.Codecs" Version="0.2.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -36,8 +36,8 @@ namespace AaxDecrypter
|
|||||||
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||||
var decryptionResult
|
var decryptionResult
|
||||||
= OutputFormat == OutputFormat.M4b
|
= OutputFormat == OutputFormat.M4b
|
||||||
? AaxFile.ConvertToMp4a(outputFile, DownloadLicense.ChapterInfo)
|
? AaxFile.ConvertToMp4a(outputFile, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength)
|
||||||
: AaxFile.ConvertToMp3(outputFile);
|
: AaxFile.ConvertToMp3(outputFile, null, DownloadLicense.ChapterInfo, DownloadLicense.TrimOutputToChapterLength);
|
||||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||||
|
|
||||||
DownloadLicense.ChapterInfo = AaxFile.Chapters;
|
DownloadLicense.ChapterInfo = AaxFile.Chapters;
|
||||||
|
|||||||
@ -10,6 +10,7 @@ namespace AaxDecrypter
|
|||||||
public string AudibleIV { get; }
|
public string AudibleIV { get; }
|
||||||
public string UserAgent { get; }
|
public string UserAgent { get; }
|
||||||
public ChapterInfo ChapterInfo { get; set; }
|
public ChapterInfo ChapterInfo { get; set; }
|
||||||
|
public bool TrimOutputToChapterLength { get; set; }
|
||||||
|
|
||||||
public DownloadLicense(string downloadUrl, string audibleKey, string audibleIV, string userAgent)
|
public DownloadLicense(string downloadUrl, string audibleKey, string audibleIV, string userAgent)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,6 +86,8 @@ namespace FileLiberator
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var config = Configuration.Instance;
|
||||||
|
|
||||||
downloadValidation(libraryBook);
|
downloadValidation(libraryBook);
|
||||||
|
|
||||||
var api = await libraryBook.GetApiAsync();
|
var api = await libraryBook.GetApiAsync();
|
||||||
@ -104,15 +106,32 @@ namespace FileLiberator
|
|||||||
//These assumptions may be wrong, and only time and bug reports will tell.
|
//These assumptions may be wrong, and only time and bug reports will tell.
|
||||||
var outputFormat =
|
var outputFormat =
|
||||||
contentLic.ContentMetadata.ContentReference.ContentFormat == "MPEG" ||
|
contentLic.ContentMetadata.ContentReference.ContentFormat == "MPEG" ||
|
||||||
(Configuration.Instance.AllowLibationFixup && Configuration.Instance.DecryptToLossy) ?
|
(config.AllowLibationFixup && config.DecryptToLossy) ?
|
||||||
OutputFormat.Mp3 : OutputFormat.M4b;
|
OutputFormat.Mp3 : OutputFormat.M4b;
|
||||||
|
|
||||||
if (Configuration.Instance.AllowLibationFixup || outputFormat == OutputFormat.Mp3)
|
audiobookDlLic.TrimOutputToChapterLength = config.StripAudibleBrandAudio;
|
||||||
{
|
|
||||||
audiobookDlLic.ChapterInfo = new AAXClean.ChapterInfo();
|
|
||||||
|
|
||||||
foreach (var chap in contentLic.ContentMetadata?.ChapterInfo?.Chapters)
|
long startMs = config.StripAudibleBrandAudio ?
|
||||||
audiobookDlLic.ChapterInfo.AddChapter(chap.Title, TimeSpan.FromMilliseconds(chap.LengthMs));
|
contentLic.ContentMetadata.ChapterInfo.BrandIntroDurationMs :
|
||||||
|
0;
|
||||||
|
|
||||||
|
if (config.AllowLibationFixup || outputFormat == OutputFormat.Mp3)
|
||||||
|
{
|
||||||
|
audiobookDlLic.ChapterInfo = new AAXClean.ChapterInfo(TimeSpan.FromMilliseconds(startMs));
|
||||||
|
|
||||||
|
for (int i = 0; i < contentLic.ContentMetadata.ChapterInfo.Chapters.Length; i++)
|
||||||
|
{
|
||||||
|
var chapter = contentLic.ContentMetadata.ChapterInfo.Chapters[i];
|
||||||
|
long chapLenMs = chapter.LengthMs;
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
chapLenMs -= startMs;
|
||||||
|
|
||||||
|
if (config.StripAudibleBrandAudio && i == contentLic.ContentMetadata.ChapterInfo.Chapters.Length - 1)
|
||||||
|
chapLenMs -= contentLic.ContentMetadata.ChapterInfo.BrandOutroDurationMs + 500; //A little more headroom at the end of the file (500 ms)
|
||||||
|
|
||||||
|
audiobookDlLic.ChapterInfo.AddChapter(chapter.Title, TimeSpan.FromMilliseconds(chapLenMs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var outFileName = AudibleFileStorage.Audio.GetInProgressFilename(libraryBook, outputFormat.ToString().ToLower());
|
var outFileName = AudibleFileStorage.Audio.GetInProgressFilename(libraryBook, outputFormat.ToString().ToLower());
|
||||||
@ -124,12 +143,12 @@ namespace FileLiberator
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
AaxcDownloadConvertBase converter
|
AaxcDownloadConvertBase converter
|
||||||
= Configuration.Instance.SplitFilesByChapter ? new AaxcDownloadMultiConverter(
|
= config.SplitFilesByChapter ? new AaxcDownloadMultiConverter(
|
||||||
outFileName, cacheDir, audiobookDlLic, outputFormat,
|
outFileName, cacheDir, audiobookDlLic, outputFormat,
|
||||||
AudibleFileStorage.Audio.CreateMultipartRenamerFunc(libraryBook))
|
AudibleFileStorage.Audio.CreateMultipartRenamerFunc(libraryBook))
|
||||||
: new AaxcDownloadSingleConverter(outFileName, cacheDir, audiobookDlLic, outputFormat);
|
: new AaxcDownloadSingleConverter(outFileName, cacheDir, audiobookDlLic, outputFormat);
|
||||||
|
|
||||||
if (Configuration.Instance.AllowLibationFixup)
|
if (config.AllowLibationFixup)
|
||||||
converter.RetrievedMetadata += (_, tags) => tags.Generes = string.Join(", ", libraryBook.Book.CategoriesNames);
|
converter.RetrievedMetadata += (_, tags) => tags.Generes = string.Join(", ", libraryBook.Book.CategoriesNames);
|
||||||
|
|
||||||
abDownloader = converter;
|
abDownloader = converter;
|
||||||
|
|||||||
@ -96,6 +96,13 @@ namespace LibationFileManager
|
|||||||
set => persistentDictionary.SetNonString(nameof(AllowLibationFixup), value);
|
set => persistentDictionary.SetNonString(nameof(AllowLibationFixup), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Description("Allow Libation to remove audible branding from the start\r\nand end of audiobooks. (e.g. \"This is Audible\")")]
|
||||||
|
public bool StripAudibleBrandAudio
|
||||||
|
{
|
||||||
|
get => persistentDictionary.GetNonString<bool>(nameof(StripAudibleBrandAudio));
|
||||||
|
set => persistentDictionary.SetNonString(nameof(StripAudibleBrandAudio), value);
|
||||||
|
}
|
||||||
|
|
||||||
[Description("Decrypt to lossy format?")]
|
[Description("Decrypt to lossy format?")]
|
||||||
public bool DecryptToLossy
|
public bool DecryptToLossy
|
||||||
{
|
{
|
||||||
|
|||||||
1017
LibationWinForms/Dialogs/SettingsDialog.Designer.cs
generated
1017
LibationWinForms/Dialogs/SettingsDialog.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,7 @@ namespace LibationWinForms.Dialogs
|
|||||||
this.inProgressDescLbl.Text = desc(nameof(config.InProgress));
|
this.inProgressDescLbl.Text = desc(nameof(config.InProgress));
|
||||||
this.allowLibationFixupCbox.Text = desc(nameof(config.AllowLibationFixup));
|
this.allowLibationFixupCbox.Text = desc(nameof(config.AllowLibationFixup));
|
||||||
this.splitFilesByChapterCbox.Text = desc(nameof(config.SplitFilesByChapter));
|
this.splitFilesByChapterCbox.Text = desc(nameof(config.SplitFilesByChapter));
|
||||||
|
this.stripAudibleBrandingCbox.Text = desc(nameof(config.StripAudibleBrandAudio));
|
||||||
|
|
||||||
booksSelectControl.SetSearchTitle("books location");
|
booksSelectControl.SetSearchTitle("books location");
|
||||||
booksSelectControl.SetDirectoryItems(
|
booksSelectControl.SetDirectoryItems(
|
||||||
@ -54,6 +55,7 @@ namespace LibationWinForms.Dialogs
|
|||||||
convertLosslessRb.Checked = !config.DecryptToLossy;
|
convertLosslessRb.Checked = !config.DecryptToLossy;
|
||||||
convertLossyRb.Checked = config.DecryptToLossy;
|
convertLossyRb.Checked = config.DecryptToLossy;
|
||||||
splitFilesByChapterCbox.Checked = config.SplitFilesByChapter;
|
splitFilesByChapterCbox.Checked = config.SplitFilesByChapter;
|
||||||
|
stripAudibleBrandingCbox.Checked = config.StripAudibleBrandAudio;
|
||||||
|
|
||||||
allowLibationFixupCbox_CheckedChanged(this, e);
|
allowLibationFixupCbox_CheckedChanged(this, e);
|
||||||
|
|
||||||
@ -174,6 +176,7 @@ namespace LibationWinForms.Dialogs
|
|||||||
config.AllowLibationFixup = allowLibationFixupCbox.Checked;
|
config.AllowLibationFixup = allowLibationFixupCbox.Checked;
|
||||||
config.DecryptToLossy = convertLossyRb.Checked;
|
config.DecryptToLossy = convertLossyRb.Checked;
|
||||||
config.SplitFilesByChapter = splitFilesByChapterCbox.Checked;
|
config.SplitFilesByChapter = splitFilesByChapterCbox.Checked;
|
||||||
|
config.StripAudibleBrandAudio = stripAudibleBrandingCbox.Checked;
|
||||||
|
|
||||||
config.InProgress = inProgressSelectControl.SelectedDirectory;
|
config.InProgress = inProgressSelectControl.SelectedDirectory;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user