Merge pull request #54 from Mbucari/master
Added Mp3 support to AAXClean.
This commit is contained in:
commit
c6e1278e42
@ -175,34 +175,41 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
public bool Step3_DownloadAndCombine()
|
public bool Step3_DownloadAndCombine()
|
||||||
{
|
{
|
||||||
DecryptProgressUpdate?.Invoke(this, int.MaxValue);
|
OutputFormat format = OutputFormat.Mp4a;
|
||||||
|
|
||||||
|
DecryptProgressUpdate?.Invoke(this, 0);
|
||||||
|
|
||||||
if (File.Exists(outputFileName))
|
if (File.Exists(outputFileName))
|
||||||
FileExt.SafeDelete(outputFileName);
|
FileExt.SafeDelete(outputFileName);
|
||||||
|
|
||||||
FileStream outFile = File.OpenWrite(outputFileName);
|
FileStream outFile = File.OpenWrite(outputFileName);
|
||||||
|
|
||||||
aaxFile.DecryptionProgressUpdate += AaxFile_DecryptionProgressUpdate;
|
aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||||
using var decryptedBook = aaxFile.DecryptAaxc(outFile, downloadLicense.AudibleKey, downloadLicense.AudibleIV, downloadLicense.ChapterInfo);
|
var decryptionResult = aaxFile.DecryptAaxc(outFile, downloadLicense.AudibleKey, downloadLicense.AudibleIV, format, downloadLicense.ChapterInfo);
|
||||||
aaxFile.DecryptionProgressUpdate -= AaxFile_DecryptionProgressUpdate;
|
aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||||
|
|
||||||
downloadLicense.ChapterInfo = aaxFile.Chapters;
|
downloadLicense.ChapterInfo = aaxFile.Chapters;
|
||||||
|
|
||||||
if (coverArt is not null)
|
if (decryptionResult == ConversionResult.NoErrorsDetected
|
||||||
|
&& coverArt is not null
|
||||||
|
&& format == OutputFormat.Mp4a)
|
||||||
{
|
{
|
||||||
decryptedBook?.AppleTags?.SetCoverArt(coverArt);
|
//This handles a special case where the aaxc file doesn't contain cover art and
|
||||||
decryptedBook?.Save();
|
//Libation downloaded it instead (Animal Farm). Currently only works for Mp4a files.
|
||||||
|
using var decryptedBook = new Mp4File(outputFileName, FileAccess.ReadWrite);
|
||||||
|
decryptedBook.AppleTags?.SetCoverArt(coverArt);
|
||||||
|
decryptedBook.Save();
|
||||||
|
decryptedBook.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
decryptedBook?.Close();
|
|
||||||
nfsPersister.Dispose();
|
nfsPersister.Dispose();
|
||||||
|
|
||||||
DecryptProgressUpdate?.Invoke(this, 0);
|
DecryptProgressUpdate?.Invoke(this, 0);
|
||||||
|
|
||||||
return aaxFile is not null && !isCanceled;
|
return decryptionResult == ConversionResult.NoErrorsDetected && !isCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AaxFile_DecryptionProgressUpdate(object sender, DecryptionProgressEventArgs e)
|
private void AaxFile_ConversionProgressUpdate(object sender, ConversionProgressEventArgs e)
|
||||||
{
|
{
|
||||||
var duration = aaxFile.Duration;
|
var duration = aaxFile.Duration;
|
||||||
double remainingSecsToProcess = (duration - e.ProcessPosition).TotalSeconds;
|
double remainingSecsToProcess = (duration - e.ProcessPosition).TotalSeconds;
|
||||||
|
|||||||
@ -64,14 +64,8 @@ namespace LibationWinForms.BookLiberation
|
|||||||
if (percentage == 0)
|
if (percentage == 0)
|
||||||
remainingTimeLbl.UIThread(() => remainingTimeLbl.Text = "ETA:\r\n0 sec");
|
remainingTimeLbl.UIThread(() => remainingTimeLbl.Text = "ETA:\r\n0 sec");
|
||||||
|
|
||||||
if (percentage == int.MaxValue)
|
|
||||||
progressBar1.UIThread(() => progressBar1.Style = ProgressBarStyle.Marquee);
|
|
||||||
else
|
else
|
||||||
progressBar1.UIThread(() =>
|
progressBar1.UIThread(() => progressBar1.Value = percentage);
|
||||||
{
|
|
||||||
progressBar1.Value = percentage;
|
|
||||||
progressBar1.Style = ProgressBarStyle.Blocks;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateRemainingTime(TimeSpan remaining)
|
public void UpdateRemainingTime(TimeSpan remaining)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user