Removed repeated code
This commit is contained in:
parent
4b78b757aa
commit
5e349c6662
@ -59,19 +59,8 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
protected override bool Step2_DownloadAudiobookAsSingleFile()
|
protected override bool Step2_DownloadAudiobookAsSingleFile()
|
||||||
{
|
{
|
||||||
var zeroProgress = new DownloadProgress
|
var zeroProgress = Step2_Start();
|
||||||
{
|
|
||||||
BytesReceived = 0,
|
|
||||||
ProgressPercentage = 0,
|
|
||||||
TotalBytesToReceive = InputFileStream.Length
|
|
||||||
};
|
|
||||||
|
|
||||||
OnDecryptProgressUpdate(zeroProgress);
|
|
||||||
|
|
||||||
|
|
||||||
aaxFile.SetDecryptionKey(downloadLicense.AudibleKey, downloadLicense.AudibleIV);
|
|
||||||
|
|
||||||
|
|
||||||
if (File.Exists(outputFileName))
|
if (File.Exists(outputFileName))
|
||||||
FileExt.SafeDelete(outputFileName);
|
FileExt.SafeDelete(outputFileName);
|
||||||
|
|
||||||
@ -81,30 +70,17 @@ namespace AaxDecrypter
|
|||||||
var decryptionResult = OutputFormat == OutputFormat.M4b ? aaxFile.ConvertToMp4a(outputFile, downloadLicense.ChapterInfo) : aaxFile.ConvertToMp3(outputFile);
|
var decryptionResult = OutputFormat == OutputFormat.M4b ? aaxFile.ConvertToMp4a(outputFile, downloadLicense.ChapterInfo) : aaxFile.ConvertToMp3(outputFile);
|
||||||
aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||||
|
|
||||||
aaxFile.Close();
|
|
||||||
|
|
||||||
downloadLicense.ChapterInfo = aaxFile.Chapters;
|
downloadLicense.ChapterInfo = aaxFile.Chapters;
|
||||||
|
|
||||||
CloseInputFileStream();
|
Step2_End(zeroProgress);
|
||||||
|
|
||||||
OnDecryptProgressUpdate(zeroProgress);
|
|
||||||
|
|
||||||
return decryptionResult == ConversionResult.NoErrorsDetected && !isCanceled;
|
return decryptionResult == ConversionResult.NoErrorsDetected && !isCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Step2_DownloadAudiobookAsMultipleFilesPerChapter()
|
private bool Step2_DownloadAudiobookAsMultipleFilesPerChapter()
|
||||||
{
|
{
|
||||||
var zeroProgress = new DownloadProgress
|
var zeroProgress = Step2_Start();
|
||||||
{
|
|
||||||
BytesReceived = 0,
|
|
||||||
ProgressPercentage = 0,
|
|
||||||
TotalBytesToReceive = InputFileStream.Length
|
|
||||||
};
|
|
||||||
|
|
||||||
OnDecryptProgressUpdate(zeroProgress);
|
|
||||||
|
|
||||||
aaxFile.SetDecryptionKey(downloadLicense.AudibleKey, downloadLicense.AudibleIV);
|
|
||||||
|
|
||||||
aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
aaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||||
if(OutputFormat == OutputFormat.M4b)
|
if(OutputFormat == OutputFormat.M4b)
|
||||||
ConvertToMultiMp4b();
|
ConvertToMultiMp4b();
|
||||||
@ -112,17 +88,40 @@ namespace AaxDecrypter
|
|||||||
ConvertToMultiMp3();
|
ConvertToMultiMp3();
|
||||||
aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
aaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||||
|
|
||||||
aaxFile.Close();
|
Step2_End(zeroProgress);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DownloadProgress Step2_Start()
|
||||||
|
{
|
||||||
|
var zeroProgress = new DownloadProgress
|
||||||
|
{
|
||||||
|
BytesReceived = 0,
|
||||||
|
ProgressPercentage = 0,
|
||||||
|
TotalBytesToReceive = InputFileStream.Length
|
||||||
|
};
|
||||||
|
|
||||||
|
OnDecryptProgressUpdate(zeroProgress);
|
||||||
|
|
||||||
|
aaxFile.SetDecryptionKey(downloadLicense.AudibleKey, downloadLicense.AudibleIV);
|
||||||
|
return zeroProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Step2_End(DownloadProgress zeroProgress)
|
||||||
|
{
|
||||||
|
aaxFile.Close();
|
||||||
|
|
||||||
|
CloseInputFileStream();
|
||||||
|
|
||||||
|
OnDecryptProgressUpdate(zeroProgress);
|
||||||
|
}
|
||||||
|
|
||||||
private void ConvertToMultiMp4b()
|
private void ConvertToMultiMp4b()
|
||||||
{
|
{
|
||||||
var chapterCount = 0;
|
var chapterCount = 0;
|
||||||
aaxFile.ConvertToMultiMp4a(downloadLicense.ChapterInfo, newSplitCallback =>
|
aaxFile.ConvertToMultiMp4a(downloadLicense.ChapterInfo, newSplitCallback =>
|
||||||
{
|
{
|
||||||
// TODO I need to find a way to inject the track number into the m4b file. It's easier with the MP3.
|
|
||||||
chapterCount++;
|
chapterCount++;
|
||||||
var fileName = Path.ChangeExtension(outputFileName, $"{chapterCount}.m4b");
|
var fileName = Path.ChangeExtension(outputFileName, $"{chapterCount}.m4b");
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
|
|||||||
@ -7,10 +7,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!--<PackageReference Include="MSBump" Version="2.3.2">
|
<PackageReference Include="MSBump" Version="2.3.2">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>-->
|
</PackageReference>
|
||||||
<PackageReference Include="Octokit" Version="0.50.0" />
|
<PackageReference Include="Octokit" Version="0.50.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user