diff --git a/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs b/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs index 1462eb0a..238a7560 100644 --- a/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs +++ b/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs @@ -29,9 +29,10 @@ namespace FileLiberator.AaxcDownloadDecrypt { bool Step1_CreateDir(); bool Step2_DownloadAndCombine(); - bool Step3_CreateCue(); - bool Step4_CreateNfo(); - bool Step5_Cleanup(); + bool Step3_InsertCoverArt(); + bool Step4_CreateCue(); + bool Step5_CreateNfo(); + bool Step6_Cleanup(); } class AaxcDownloadConverter : IAdvancedAaxcToM4bConverter { @@ -71,9 +72,10 @@ namespace FileLiberator.AaxcDownloadDecrypt ["Step 1: Create Dir"] = Step1_CreateDir, ["Step 2: Download and Combine Audiobook"] = Step2_DownloadAndCombine, - ["Step 3 Create Cue"] = Step3_CreateCue, - ["Step 4 Create Nfo"] = Step4_CreateNfo, - ["Step 5: Cleanup"] = Step5_Cleanup, + ["Step 3 Insert Cover Art"] = Step3_InsertCoverArt, + ["Step 4 Create Cue"] = Step4_CreateCue, + ["Step 5 Create Nfo"] = Step5_CreateNfo, + ["Step 6: Cleanup"] = Step6_Cleanup, }; downloadLicense = dlLic; @@ -135,8 +137,6 @@ namespace FileLiberator.AaxcDownloadDecrypt public bool Step2_DownloadAndCombine() { - File.WriteAllBytes(coverArtPath, tags.coverArt); - var ffmpegTags = tags.GenerateFfmpegTags(); var ffmpegChapters = GenerateFfmpegChapters(chapters); @@ -152,7 +152,6 @@ namespace FileLiberator.AaxcDownloadDecrypt Resources.UserAgent, downloadLicense.AudibleKey, downloadLicense.AudibleIV, - coverArtPath, metadataPath, outputFileName) .GetAwaiter() @@ -177,21 +176,37 @@ namespace FileLiberator.AaxcDownloadDecrypt return stringBuilder.ToString(); } - public bool Step3_CreateCue() + public bool Step3_InsertCoverArt() + { + + File.WriteAllBytes(coverArtPath, tags.coverArt); + + var insertCoverArtInfo = new System.Diagnostics.ProcessStartInfo + { + FileName = DecryptSupportLibraries.atomicParsleyPath, + Arguments = "\"" + outputFileName + "\" --encodingTool \"" + AppName + "\" --artwork \"" + coverArtPath + "\" --overWrite" + }; + insertCoverArtInfo.RunHidden(); + + // delete temp file + FileExt.SafeDelete(coverArtPath); + + return true; + } + public bool Step4_CreateCue() { File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".cue"), Cue.CreateContents(Path.GetFileName(outputFileName), chapters)); return true; } - public bool Step4_CreateNfo() + public bool Step5_CreateNfo() { File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".nfo"), NFO.CreateContents(AppName, tags, chapters)); return true; } - public bool Step5_Cleanup() + public bool Step6_Cleanup() { - FileExt.SafeDelete(coverArtPath); FileExt.SafeDelete(metadataPath); return true; } diff --git a/FileLiberator/AaxcDownloadDecrypt/FFMpegAaaxcProcesser.cs b/FileLiberator/AaxcDownloadDecrypt/FFMpegAaaxcProcesser.cs index 5adbd403..29ba37d1 100644 --- a/FileLiberator/AaxcDownloadDecrypt/FFMpegAaaxcProcesser.cs +++ b/FileLiberator/AaxcDownloadDecrypt/FFMpegAaaxcProcesser.cs @@ -32,7 +32,7 @@ namespace FileLiberator.AaxcDownloadDecrypt FFMpegPath = ffmpegPath; } - public async Task ProcessBook(string aaxcUrl, string userAgent, string audibleKey, string audibleIV, string artworkPath, string metadataPath, string outputFile) + public async Task ProcessBook(string aaxcUrl, string userAgent, string audibleKey, string audibleIV, string metadataPath, string outputFile) { //This process gets the aaxc from the url and streams the decrypted //aac stream to standard output @@ -45,7 +45,7 @@ namespace FileLiberator.AaxcDownloadDecrypt // it into an m4b along with the cover art and metadata. var remuxer = new Process { - StartInfo = getRemuxerStartInfo(artworkPath, metadataPath, outputFile) + StartInfo = getRemuxerStartInfo(metadataPath, outputFile) }; IsRunning = true; @@ -156,7 +156,7 @@ namespace FileLiberator.AaxcDownloadDecrypt } }; - private ProcessStartInfo getRemuxerStartInfo(string artworkPath, string metadataPath, string outputFile) => + private ProcessStartInfo getRemuxerStartInfo(string metadataPath, string outputFile) => new ProcessStartInfo { FileName = FFMpegPath, @@ -176,21 +176,13 @@ namespace FileLiberator.AaxcDownloadDecrypt "-i", "pipe:", //input from standard input "-i", - artworkPath, - "-i", metadataPath, "-map", "0", - "-map", - "1", "-map_metadata", - "2", + "1", "-c", //codec copy - "copy", - "-c:v:1", //video codec from file [1] (artwork) - "png", //video codec - "-disposition:v:1", - "attached_pic", + "copy", "-f", //force output format: mp4 "mp4", outputFile, diff --git a/FileLiberator/DecryptLib/AtomicParsley.exe b/FileLiberator/DecryptLib/AtomicParsley.exe new file mode 100644 index 00000000..47040f64 Binary files /dev/null and b/FileLiberator/DecryptLib/AtomicParsley.exe differ diff --git a/FileLiberator/FileLiberator.csproj b/FileLiberator/FileLiberator.csproj index afb234e0..526123a8 100644 --- a/FileLiberator/FileLiberator.csproj +++ b/FileLiberator/FileLiberator.csproj @@ -20,6 +20,9 @@ + + Always + Always