Merge pull request #450 from Mbucari/master
Update workflows and AAXClean
This commit is contained in:
commit
9be0d58461
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -14,7 +14,12 @@ on:
|
||||
type: boolean
|
||||
description: 'Skip running unit tests'
|
||||
required: false
|
||||
default: true
|
||||
default: true
|
||||
build_deb:
|
||||
type: boolean
|
||||
description: 'Build Debian package'
|
||||
required: false
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
@ -31,6 +36,7 @@ jobs:
|
||||
|
||||
linux_deb:
|
||||
needs: [linux]
|
||||
if: inputs.build_deb
|
||||
uses: ./.github/workflows/build-deb.yml
|
||||
with:
|
||||
version: ${{ needs.linux.outputs.version }}
|
||||
|
||||
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@ -33,6 +33,7 @@ jobs:
|
||||
with:
|
||||
version_override: ${{ needs.prerelease.outputs.version }}
|
||||
run_unit_tests: false
|
||||
build_deb: true
|
||||
|
||||
release:
|
||||
needs: [prerelease,build]
|
||||
@ -50,7 +51,7 @@ jobs:
|
||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||
with:
|
||||
tag_name: '${{ github.ref }}'
|
||||
release_name: 'Libation ${{ steps.version.outputs.version }}'
|
||||
release_name: 'Libation ${{ needs.prerelease.outputs.version }}'
|
||||
body: <Put a body here>
|
||||
draft: true
|
||||
prerelease: false
|
||||
|
||||
3
.github/workflows/scripts/targz2deb.sh
vendored
3
.github/workflows/scripts/targz2deb.sh
vendored
@ -105,6 +105,9 @@ ln -s /usr/lib/libation/Libation /usr/bin/libation
|
||||
ln -s /usr/lib/libation/Hangover /usr/bin/hangover
|
||||
ln -s /usr/lib/libation/LibationCli /usr/bin/libationcli
|
||||
|
||||
# Increase the maximum number of inotify instances
|
||||
echo fs.inotify.max_user_instances=524288 | tee -a /etc/sysctl.conf && sysctl -p
|
||||
|
||||
# workaround until this file is moved to the user's home directory
|
||||
touch /usr/lib/libation/appsettings.json
|
||||
chmod 666 /usr/lib/libation/appsettings.json
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AAXClean.Codecs" Version="0.3.1" />
|
||||
<PackageReference Include="AAXClean.Codecs" Version="0.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -13,6 +13,7 @@ namespace AaxDecrypter
|
||||
{
|
||||
private static TimeSpan minChapterLength { get; } = TimeSpan.FromSeconds(3);
|
||||
private List<string> multiPartFilePaths { get; } = new List<string>();
|
||||
private FileStream workingFileStream;
|
||||
|
||||
public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, IDownloadOptions dlOptions)
|
||||
: base(outFileName, cacheDirectory, dlOptions) { }
|
||||
@ -130,18 +131,31 @@ That naming may not be desirable for everyone, but it's an easy change to instea
|
||||
// reset, just in case
|
||||
multiPartFilePaths.Clear();
|
||||
|
||||
ConversionResult result;
|
||||
try
|
||||
{
|
||||
ConversionResult result;
|
||||
|
||||
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
if (DownloadOptions.OutputFormat == OutputFormat.M4b)
|
||||
result = await ConvertToMultiMp4a(splitChapters);
|
||||
else
|
||||
result = await ConvertToMultiMp3(splitChapters);
|
||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
if (DownloadOptions.OutputFormat == OutputFormat.M4b)
|
||||
result = await ConvertToMultiMp4a(splitChapters);
|
||||
else
|
||||
result = await ConvertToMultiMp3(splitChapters);
|
||||
|
||||
Step_DownloadAudiobook_End(zeroProgress);
|
||||
return result == ConversionResult.NoErrorsDetected;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "AAXClean Error");
|
||||
workingFileStream?.Close();
|
||||
FileUtility.SaferDelete(workingFileStream.Name);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
|
||||
return result == ConversionResult.NoErrorsDetected;
|
||||
Step_DownloadAudiobook_End(zeroProgress);
|
||||
}
|
||||
}
|
||||
|
||||
private Task<ConversionResult> ConvertToMultiMp4a(ChapterInfo splitChapters)
|
||||
@ -195,9 +209,9 @@ That naming may not be desirable for everyone, but it's an easy change to instea
|
||||
|
||||
FileUtility.SaferDelete(fileName);
|
||||
|
||||
var file = File.Open(fileName, FileMode.OpenOrCreate);
|
||||
workingFileStream = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||
OnFileCreated(fileName);
|
||||
return file;
|
||||
return workingFileStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,17 +92,28 @@ namespace AaxDecrypter
|
||||
|
||||
AaxFile.ConversionProgressUpdate += AaxFile_ConversionProgressUpdate;
|
||||
|
||||
ConversionResult decryptionResult = await decryptAsync(outputFile);
|
||||
try
|
||||
{
|
||||
ConversionResult decryptionResult = await decryptAsync(outputFile);
|
||||
var success = decryptionResult == ConversionResult.NoErrorsDetected && !IsCanceled;
|
||||
if (success)
|
||||
base.OnFileCreated(OutputFileName);
|
||||
|
||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
return success;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "AAXClean Error");
|
||||
FileUtility.SaferDelete(OutputFileName);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
outputFile.Close();
|
||||
AaxFile.ConversionProgressUpdate -= AaxFile_ConversionProgressUpdate;
|
||||
|
||||
Step_DownloadAudiobook_End(zeroProgress);
|
||||
|
||||
var success = decryptionResult == ConversionResult.NoErrorsDetected && !IsCanceled;
|
||||
if (success)
|
||||
base.OnFileCreated(OutputFileName);
|
||||
|
||||
return success;
|
||||
Step_DownloadAudiobook_End(zeroProgress);
|
||||
}
|
||||
}
|
||||
|
||||
private Task<ConversionResult> decryptAsync(Stream outputFile)
|
||||
|
||||
@ -64,30 +64,40 @@ namespace FileLiberator
|
||||
config.LameMatchSourceBR);
|
||||
|
||||
using var mp3File = File.OpenWrite(Path.GetTempFileName());
|
||||
var result = await m4bBook.ConvertToMp3Async(mp3File, lameConfig);
|
||||
m4bBook.InputStream.Close();
|
||||
mp3File.Close();
|
||||
|
||||
if (result == ConversionResult.Failed)
|
||||
try
|
||||
{
|
||||
FileUtility.SaferDelete(mp3File.Name);
|
||||
var result = await m4bBook.ConvertToMp3Async(mp3File, lameConfig);
|
||||
|
||||
var realMp3Path = FileUtility.SaferMoveToValidPath(mp3File.Name, proposedMp3Path, Configuration.Instance.ReplacementCharacters);
|
||||
OnFileCreated(libraryBook, realMp3Path);
|
||||
|
||||
if (result == ConversionResult.Failed)
|
||||
{
|
||||
FileUtility.SaferDelete(mp3File.Name);
|
||||
}
|
||||
else if (result == ConversionResult.Cancelled)
|
||||
{
|
||||
FileUtility.SaferDelete(mp3File.Name);
|
||||
return new StatusHandler { "Cancelled" };
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "AAXClean error");
|
||||
return new StatusHandler { "Conversion failed" };
|
||||
}
|
||||
else if (result == ConversionResult.Cancelled)
|
||||
finally
|
||||
{
|
||||
FileUtility.SaferDelete(mp3File.Name);
|
||||
return new StatusHandler { "Cancelled" };
|
||||
m4bBook.InputStream.Close();
|
||||
mp3File.Close();
|
||||
}
|
||||
|
||||
var realMp3Path = FileUtility.SaferMoveToValidPath(mp3File.Name, proposedMp3Path, Configuration.Instance.ReplacementCharacters);
|
||||
OnFileCreated(libraryBook, realMp3Path);
|
||||
}
|
||||
return new StatusHandler();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnCompleted(libraryBook);
|
||||
}
|
||||
return new StatusHandler();
|
||||
}
|
||||
|
||||
private void M4bBook_ConversionProgressUpdate(object sender, ConversionProgressEventArgs e)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user