Added AtomicParsley back in because ffmpeg cover art wasn't working.

This commit is contained in:
Michael Bucari-Tovo 2021-06-24 17:53:09 -06:00
parent 81d0f87b8a
commit 06549e5b4e
4 changed files with 36 additions and 26 deletions

View File

@ -29,9 +29,10 @@ namespace FileLiberator.AaxcDownloadDecrypt
{ {
bool Step1_CreateDir(); bool Step1_CreateDir();
bool Step2_DownloadAndCombine(); bool Step2_DownloadAndCombine();
bool Step3_CreateCue(); bool Step3_InsertCoverArt();
bool Step4_CreateNfo(); bool Step4_CreateCue();
bool Step5_Cleanup(); bool Step5_CreateNfo();
bool Step6_Cleanup();
} }
class AaxcDownloadConverter : IAdvancedAaxcToM4bConverter class AaxcDownloadConverter : IAdvancedAaxcToM4bConverter
{ {
@ -71,9 +72,10 @@ namespace FileLiberator.AaxcDownloadDecrypt
["Step 1: Create Dir"] = Step1_CreateDir, ["Step 1: Create Dir"] = Step1_CreateDir,
["Step 2: Download and Combine Audiobook"] = Step2_DownloadAndCombine, ["Step 2: Download and Combine Audiobook"] = Step2_DownloadAndCombine,
["Step 3 Create Cue"] = Step3_CreateCue, ["Step 3 Insert Cover Art"] = Step3_InsertCoverArt,
["Step 4 Create Nfo"] = Step4_CreateNfo, ["Step 4 Create Cue"] = Step4_CreateCue,
["Step 5: Cleanup"] = Step5_Cleanup, ["Step 5 Create Nfo"] = Step5_CreateNfo,
["Step 6: Cleanup"] = Step6_Cleanup,
}; };
downloadLicense = dlLic; downloadLicense = dlLic;
@ -135,8 +137,6 @@ namespace FileLiberator.AaxcDownloadDecrypt
public bool Step2_DownloadAndCombine() public bool Step2_DownloadAndCombine()
{ {
File.WriteAllBytes(coverArtPath, tags.coverArt);
var ffmpegTags = tags.GenerateFfmpegTags(); var ffmpegTags = tags.GenerateFfmpegTags();
var ffmpegChapters = GenerateFfmpegChapters(chapters); var ffmpegChapters = GenerateFfmpegChapters(chapters);
@ -152,7 +152,6 @@ namespace FileLiberator.AaxcDownloadDecrypt
Resources.UserAgent, Resources.UserAgent,
downloadLicense.AudibleKey, downloadLicense.AudibleKey,
downloadLicense.AudibleIV, downloadLicense.AudibleIV,
coverArtPath,
metadataPath, metadataPath,
outputFileName) outputFileName)
.GetAwaiter() .GetAwaiter()
@ -177,21 +176,37 @@ namespace FileLiberator.AaxcDownloadDecrypt
return stringBuilder.ToString(); 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)); File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".cue"), Cue.CreateContents(Path.GetFileName(outputFileName), chapters));
return true; return true;
} }
public bool Step4_CreateNfo() public bool Step5_CreateNfo()
{ {
File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".nfo"), NFO.CreateContents(AppName, tags, chapters)); File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".nfo"), NFO.CreateContents(AppName, tags, chapters));
return true; return true;
} }
public bool Step5_Cleanup() public bool Step6_Cleanup()
{ {
FileExt.SafeDelete(coverArtPath);
FileExt.SafeDelete(metadataPath); FileExt.SafeDelete(metadataPath);
return true; return true;
} }

View File

@ -32,7 +32,7 @@ namespace FileLiberator.AaxcDownloadDecrypt
FFMpegPath = ffmpegPath; 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 //This process gets the aaxc from the url and streams the decrypted
//aac stream to standard output //aac stream to standard output
@ -45,7 +45,7 @@ namespace FileLiberator.AaxcDownloadDecrypt
// it into an m4b along with the cover art and metadata. // it into an m4b along with the cover art and metadata.
var remuxer = new Process var remuxer = new Process
{ {
StartInfo = getRemuxerStartInfo(artworkPath, metadataPath, outputFile) StartInfo = getRemuxerStartInfo(metadataPath, outputFile)
}; };
IsRunning = true; 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 new ProcessStartInfo
{ {
FileName = FFMpegPath, FileName = FFMpegPath,
@ -176,21 +176,13 @@ namespace FileLiberator.AaxcDownloadDecrypt
"-i", "-i",
"pipe:", //input from standard input "pipe:", //input from standard input
"-i", "-i",
artworkPath,
"-i",
metadataPath, metadataPath,
"-map", "-map",
"0", "0",
"-map",
"1",
"-map_metadata", "-map_metadata",
"2", "1",
"-c", //codec copy "-c", //codec copy
"copy", "copy",
"-c:v:1", //video codec from file [1] (artwork)
"png", //video codec
"-disposition:v:1",
"attached_pic",
"-f", //force output format: mp4 "-f", //force output format: mp4
"mp4", "mp4",
outputFile, outputFile,

Binary file not shown.

View File

@ -20,6 +20,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="DecryptLib\AtomicParsley.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DecryptLib\avcodec-58.dll"> <None Update="DecryptLib\avcodec-58.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>