Audible whack-a-mole: they changed how to download pdfs
This commit is contained in:
parent
dfc4121ab0
commit
4509b8c8eb
@ -45,7 +45,7 @@ namespace FileLiberator
|
||||
{
|
||||
validate(libraryBook);
|
||||
|
||||
var api = await AudibleApiActions.GetApiAsync(libraryBook.Account, libraryBook.Book.Locale);
|
||||
var api = await GetApiAsync(libraryBook);
|
||||
|
||||
var actualFilePath = await PerformDownloadAsync(
|
||||
tempAaxFilename,
|
||||
|
||||
@ -41,7 +41,8 @@ namespace FileLiberator
|
||||
|
||||
private async Task downloadPdfAsync(LibraryBook libraryBook, string proposedDownloadFilePath)
|
||||
{
|
||||
var downloadUrl = getdownloadUrl(libraryBook);
|
||||
var api = await GetApiAsync(libraryBook);
|
||||
var downloadUrl = await api.GetPdfDownloadLinkAsync(libraryBook.Book.AudibleProductId);
|
||||
|
||||
var client = new HttpClient();
|
||||
var actualDownloadedFilePath = await PerformDownloadAsync(
|
||||
|
||||
@ -38,6 +38,9 @@ namespace FileLiberator
|
||||
}
|
||||
}
|
||||
|
||||
protected static Task<AudibleApi.Api> GetApiAsync(LibraryBook libraryBook)
|
||||
=> InternalUtilities.AudibleApiActions.GetApiAsync(libraryBook.Account, libraryBook.Book.Locale);
|
||||
|
||||
protected async Task<string> PerformDownloadAsync(string proposedDownloadFilePath, Func<Progress<DownloadProgress>, Task<string>> func)
|
||||
{
|
||||
var progress = new Progress<DownloadProgress>();
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
|
||||
<Version>4.0.6.4</Version>
|
||||
<Version>4.0.7.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -27,9 +27,7 @@
|
||||
<Compile Update="UNTESTED\Dialogs\LibationFilesDialog.Designer.cs">
|
||||
<DependentUpon>LibationFilesDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="UNTESTED\Dialogs\ScanAccountsDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UNTESTED\Dialogs\ScanAccountsDialog.cs" />
|
||||
<Compile Update="UNTESTED\Dialogs\ScanAccountsDialog.Designer.cs">
|
||||
<DependentUpon>ScanAccountsDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@ -17,15 +17,15 @@ namespace LibationWinForms.BookLiberation
|
||||
// thread-safe UI updates
|
||||
public void UpdateFilename(string title) => filenameLbl.UIThread(() => filenameLbl.Text = title);
|
||||
|
||||
public void DownloadProgressChanged(long BytesReceived, long TotalBytesToReceive)
|
||||
public void DownloadProgressChanged(long BytesReceived, long? TotalBytesToReceive)
|
||||
{
|
||||
// this won't happen with download file. it will happen with download string
|
||||
if (TotalBytesToReceive < 0)
|
||||
if (!TotalBytesToReceive.HasValue || TotalBytesToReceive.Value <= 0)
|
||||
return;
|
||||
|
||||
progressLbl.UIThread(() => progressLbl.Text = $"{BytesReceived:#,##0} of {TotalBytesToReceive:#,##0}");
|
||||
progressLbl.UIThread(() => progressLbl.Text = $"{BytesReceived:#,##0} of {TotalBytesToReceive.Value:#,##0}");
|
||||
|
||||
var d = double.Parse(BytesReceived.ToString()) / double.Parse(TotalBytesToReceive.ToString()) * 100.0;
|
||||
var d = double.Parse(BytesReceived.ToString()) / double.Parse(TotalBytesToReceive.Value.ToString()) * 100.0;
|
||||
var i = int.Parse(Math.Truncate(d).ToString());
|
||||
progressBar1.UIThread(() => progressBar1.Value = i);
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ namespace LibationWinForms.BookLiberation
|
||||
downloadDialog.UpdateFilename(str);
|
||||
downloadDialog.Show();
|
||||
};
|
||||
downloadFile.DownloadProgressChanged += (_, progress) => downloadDialog.DownloadProgressChanged(progress.BytesReceived, progress.TotalBytesToReceive.Value);
|
||||
downloadFile.DownloadProgressChanged += (_, progress) => downloadDialog.DownloadProgressChanged(progress.BytesReceived, progress.TotalBytesToReceive);
|
||||
downloadFile.DownloadCompleted += (_, __) => downloadDialog.Close();
|
||||
|
||||
await downloadFile.PerformDownloadFileAsync(url, destination);
|
||||
@ -161,7 +161,7 @@ namespace LibationWinForms.BookLiberation
|
||||
void fileDownloadCompleted(object _, string __) => downloadDialog.Close();
|
||||
|
||||
void downloadProgressChanged(object _, Dinah.Core.Net.Http.DownloadProgress progress)
|
||||
=> downloadDialog.DownloadProgressChanged(progress.BytesReceived, progress.TotalBytesToReceive.Value);
|
||||
=> downloadDialog.DownloadProgressChanged(progress.BytesReceived, progress.TotalBytesToReceive);
|
||||
|
||||
void unsubscribe(object _ = null, EventArgs __ = null)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user