Upgrade AAXClean.Codecs to 0.5.10 and fix #459
This commit is contained in:
parent
d0727b5a85
commit
7029409792
8 changed files with 57 additions and 45 deletions
|
|
@ -13,7 +13,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AAXClean.Codecs" Version="0.5.0" />
|
||||
<PackageReference Include="AAXClean.Codecs" Version="0.5.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace AaxDecrypter
|
|||
public event EventHandler<AppleTags> RetrievedMetadata;
|
||||
|
||||
protected AaxFile AaxFile;
|
||||
protected Mp4Operation aaxConversion;
|
||||
|
||||
protected AaxcDownloadConvertBase(string outFileName, string cacheDirectory, IDownloadOptions dlOptions)
|
||||
: base(outFileName, cacheDirectory, dlOptions) { }
|
||||
|
|
@ -101,9 +102,9 @@ namespace AaxDecrypter
|
|||
public override async Task CancelAsync()
|
||||
{
|
||||
IsCanceled = true;
|
||||
if (AaxFile != null)
|
||||
await AaxFile.CancelAsync();
|
||||
AaxFile?.Dispose();
|
||||
if (aaxConversion != null)
|
||||
await aaxConversion.CancelAsync();
|
||||
AaxFile?.Close();
|
||||
CloseInputFileStream();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,32 +133,33 @@ That naming may not be desirable for everyone, but it's an easy change to instea
|
|||
|
||||
try
|
||||
{
|
||||
ConversionResult result;
|
||||
|
||||
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
if (DownloadOptions.OutputFormat == OutputFormat.M4b)
|
||||
result = await ConvertToMultiMp4a(splitChapters);
|
||||
aaxConversion = ConvertToMultiMp4a(splitChapters);
|
||||
else
|
||||
result = await ConvertToMultiMp3(splitChapters);
|
||||
aaxConversion = ConvertToMultiMp3(splitChapters);
|
||||
|
||||
return result == ConversionResult.NoErrorsDetected;
|
||||
aaxConversion.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
await aaxConversion;
|
||||
return aaxConversion.IsCompletedSuccessfully;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "AAXClean Error");
|
||||
workingFileStream?.Close();
|
||||
FileUtility.SaferDelete(workingFileStream.Name);
|
||||
if (workingFileStream?.Name is not null)
|
||||
FileUtility.SaferDelete(workingFileStream.Name);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
if (aaxConversion is not null)
|
||||
aaxConversion.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
|
||||
Step_DownloadAudiobook_End(zeroProgress);
|
||||
}
|
||||
}
|
||||
|
||||
private Task<ConversionResult> ConvertToMultiMp4a(ChapterInfo splitChapters)
|
||||
private Mp4Operation ConvertToMultiMp4a(ChapterInfo splitChapters)
|
||||
{
|
||||
var chapterCount = 0;
|
||||
return AaxFile.ConvertToMultiMp4aAsync
|
||||
|
|
@ -169,7 +170,7 @@ That naming may not be desirable for everyone, but it's an easy change to instea
|
|||
);
|
||||
}
|
||||
|
||||
private Task<ConversionResult> ConvertToMultiMp3(ChapterInfo splitChapters)
|
||||
private Mp4Operation ConvertToMultiMp3(ChapterInfo splitChapters)
|
||||
{
|
||||
var chapterCount = 0;
|
||||
return AaxFile.ConvertToMultiMp3Async
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||
using AAXClean;
|
||||
using AAXClean.Codecs;
|
||||
using FileManager;
|
||||
using Mpeg4Lib.Util;
|
||||
|
||||
namespace AaxDecrypter
|
||||
{
|
||||
|
|
@ -90,16 +91,20 @@ namespace AaxDecrypter
|
|||
var outputFile = File.Open(OutputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||
OnFileCreated(OutputFileName);
|
||||
|
||||
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
|
||||
try
|
||||
{
|
||||
ConversionResult decryptionResult = await decryptAsync(outputFile);
|
||||
var success = decryptionResult == ConversionResult.NoErrorsDetected && !IsCanceled;
|
||||
if (success)
|
||||
base.OnFileCreated(OutputFileName);
|
||||
aaxConversion = decryptAsync(outputFile);
|
||||
aaxConversion.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
await aaxConversion;
|
||||
|
||||
return success;
|
||||
if (aaxConversion.IsCompletedSuccessfully)
|
||||
{
|
||||
outputFile.Close();
|
||||
base.OnFileCreated(OutputFileName);
|
||||
}
|
||||
|
||||
return aaxConversion.IsCompletedSuccessfully;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
|
@ -110,13 +115,15 @@ namespace AaxDecrypter
|
|||
finally
|
||||
{
|
||||
outputFile.Close();
|
||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
|
||||
if (aaxConversion is not null)
|
||||
aaxConversion.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
|
||||
Step_DownloadAudiobook_End(zeroProgress);
|
||||
}
|
||||
}
|
||||
|
||||
private Task<ConversionResult> decryptAsync(Stream outputFile)
|
||||
private Mp4Operation decryptAsync(Stream outputFile)
|
||||
=> DownloadOptions.OutputFormat == OutputFormat.Mp3 ?
|
||||
AaxFile.ConvertToMp3Async
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue