Better naming.

This commit is contained in:
Michael Bucari-Tovo 2021-10-06 08:23:07 -06:00
parent 07c96c4994
commit 8098564926
3 changed files with 43 additions and 13 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>6.2.1.0</Version>
<Version>6.2.1.6</Version>
</PropertyGroup>
<ItemGroup>

View File

@ -14,7 +14,7 @@ namespace FileLiberator
{
public class DownloadDecryptBook : AudioDecodable
{
private AudiobookDownloadBase aaxcDownloader;
private AudiobookDownloadBase abDownloader;
public override async Task<StatusHandler> ProcessAsync(LibraryBook libraryBook)
{
@ -84,18 +84,19 @@ namespace FileLiberator
var outFileName = Path.Combine(destinationDir, $"{PathLib.ToPathSafeString(libraryBook.Book.Title)} [{libraryBook.Book.AudibleProductId}].{outputFormat.ToString().ToLower()}");
aaxcDownloader = contentLic.DrmType == AudibleApi.Common.DrmType.Adrm
? new AaxcDownloadConverter(outFileName, cacheDir, audiobookDlLic, outputFormat, Configuration.Instance.SplitFilesByChapter) { AppName = "Libation" }
abDownloader = contentLic.DrmType == AudibleApi.Common.DrmType.Adrm
? new AaxcDownloadConverter(outFileName, cacheDir, audiobookDlLic, outputFormat, Configuration.Instance.SplitFilesByChapter)
: new UnencryptedAudiobookDownloader(outFileName, cacheDir, audiobookDlLic);
aaxcDownloader.DecryptProgressUpdate += (s, progress) => OnStreamingProgressChanged(progress);
aaxcDownloader.DecryptTimeRemaining += (s, remaining) => OnStreamingTimeRemaining(remaining);
aaxcDownloader.RetrievedTitle += (s, title) => OnTitleDiscovered(title);
aaxcDownloader.RetrievedAuthors += (s, authors) => OnAuthorsDiscovered(authors);
aaxcDownloader.RetrievedNarrators += (s, narrators) => OnNarratorsDiscovered(narrators);
aaxcDownloader.RetrievedCoverArt += AaxcDownloader_RetrievedCoverArt;
abDownloader.AppName = "Libation";
abDownloader.DecryptProgressUpdate += (s, progress) => OnStreamingProgressChanged(progress);
abDownloader.DecryptTimeRemaining += (s, remaining) => OnStreamingTimeRemaining(remaining);
abDownloader.RetrievedTitle += (s, title) => OnTitleDiscovered(title);
abDownloader.RetrievedAuthors += (s, authors) => OnAuthorsDiscovered(authors);
abDownloader.RetrievedNarrators += (s, narrators) => OnNarratorsDiscovered(narrators);
abDownloader.RetrievedCoverArt += AaxcDownloader_RetrievedCoverArt;
// REAL WORK DONE HERE
var success = await Task.Run(() => aaxcDownloader.Run());
var success = await Task.Run(abDownloader.Run);
// decrypt failed
if (!success)
@ -113,7 +114,7 @@ namespace FileLiberator
{
if (e is null && Configuration.Instance.AllowLibationFixup)
{
OnRequestCoverArt(aaxcDownloader.SetCoverArt);
OnRequestCoverArt(abDownloader.SetCoverArt);
}
if (e is not null)
@ -204,7 +205,7 @@ namespace FileLiberator
public override void Cancel()
{
aaxcDownloader?.Cancel();
abDownloader?.Cancel();
}
}
}

View File

@ -0,0 +1,29 @@
using System.ComponentModel;
using System.Windows.Forms;
namespace LibationWinForms
{
public class TruncatedDataGridViewTextBoxColumn : DataGridViewTextBoxColumn
{
public TruncatedDataGridViewTextBoxColumn()
{
CellTemplate = new TruncatedDataGridViewTextBoxCell();
}
}
internal class TruncatedDataGridViewTextBoxCell : DataGridViewTextBoxCell
{
private const int MAX_DISPLAY_CHARS = 63;
private string truncatedString;
protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
{
if (value is null || value is not string valueStr)
return value;
truncatedString ??= valueStr.Length < MAX_DISPLAY_CHARS ? valueStr : valueStr.Substring(0, MAX_DISPLAY_CHARS - 1) + "…";
return truncatedString;
}
}
}