Use new AudibleApi Dtos.
This commit is contained in:
parent
25d89207bb
commit
00f8a63781
@ -20,7 +20,7 @@ namespace AaxDecrypter
|
||||
string AppName { get; set; }
|
||||
string outDir { get; }
|
||||
string outputFileName { get; }
|
||||
ChapterInfo chapters { get; }
|
||||
DownloadLicense downloadLicense { get; }
|
||||
AaxcTagLibFile aaxcTagLib { get; }
|
||||
byte[] coverArt { get; }
|
||||
void SetCoverArt(byte[] coverArt);
|
||||
@ -45,23 +45,22 @@ namespace AaxDecrypter
|
||||
public string AppName { get; set; } = nameof(AaxcDownloadConverter);
|
||||
public string outDir { get; private set; }
|
||||
public string outputFileName { get; private set; }
|
||||
public ChapterInfo chapters { get; private set; }
|
||||
public DownloadLicense downloadLicense { get; private set; }
|
||||
public AaxcTagLibFile aaxcTagLib { get; private set; }
|
||||
public byte[] coverArt { get; private set; }
|
||||
|
||||
private StepSequence steps { get; }
|
||||
private DownloadLicense downloadLicense { get; set; }
|
||||
private FFMpegAaxcProcesser aaxcProcesser;
|
||||
private bool isCanceled { get; set; }
|
||||
|
||||
public static AaxcDownloadConverter Create(string outDirectory, DownloadLicense dlLic, ChapterInfo chapters = null)
|
||||
public static AaxcDownloadConverter Create(string outDirectory, DownloadLicense dlLic)
|
||||
{
|
||||
var converter = new AaxcDownloadConverter(outDirectory, dlLic, chapters);
|
||||
var converter = new AaxcDownloadConverter(outDirectory, dlLic);
|
||||
converter.SetOutputFilename(Path.GetTempFileName());
|
||||
return converter;
|
||||
}
|
||||
|
||||
private AaxcDownloadConverter(string outDirectory, DownloadLicense dlLic, ChapterInfo chapters)
|
||||
private AaxcDownloadConverter(string outDirectory, DownloadLicense dlLic)
|
||||
{
|
||||
ArgumentValidator.EnsureNotNullOrWhiteSpace(outDirectory, nameof(outDirectory));
|
||||
ArgumentValidator.EnsureNotNull(dlLic, nameof(dlLic));
|
||||
@ -86,7 +85,6 @@ namespace AaxDecrypter
|
||||
aaxcProcesser.ProgressUpdate += AaxcProcesser_ProgressUpdate;
|
||||
|
||||
downloadLicense = dlLic;
|
||||
this.chapters = chapters;
|
||||
}
|
||||
|
||||
public void SetOutputFilename(string outFileName)
|
||||
@ -153,7 +151,8 @@ namespace AaxDecrypter
|
||||
public bool Step3_DownloadAndCombine()
|
||||
{
|
||||
DecryptProgressUpdate?.Invoke(this, int.MaxValue);
|
||||
bool userSuppliedChapters = chapters != null;
|
||||
|
||||
bool userSuppliedChapters = downloadLicense.ChapterInfo != null;
|
||||
|
||||
string metadataPath = null;
|
||||
|
||||
@ -162,7 +161,7 @@ namespace AaxDecrypter
|
||||
//Only write chaopters to the metadata file. All other aaxc metadata will be
|
||||
//wiped out but is restored in Step 3.
|
||||
metadataPath = Path.Combine(outDir, Path.GetFileName(outputFileName) + ".ffmeta");
|
||||
File.WriteAllText(metadataPath, chapters.ToFFMeta(true));
|
||||
File.WriteAllText(metadataPath, downloadLicense.ChapterInfo.ToFFMeta(true));
|
||||
}
|
||||
|
||||
aaxcProcesser.ProcessBook(
|
||||
@ -172,7 +171,7 @@ namespace AaxDecrypter
|
||||
.GetResult();
|
||||
|
||||
if (!userSuppliedChapters && aaxcProcesser.Succeeded)
|
||||
chapters = new ChapterInfo(outputFileName);
|
||||
downloadLicense.ChapterInfo = new ChapterInfo(outputFileName);
|
||||
|
||||
if (userSuppliedChapters)
|
||||
FileExt.SafeDelete(metadataPath);
|
||||
@ -215,13 +214,13 @@ namespace AaxDecrypter
|
||||
|
||||
public bool Step5_CreateCue()
|
||||
{
|
||||
File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".cue"), Cue.CreateContents(Path.GetFileName(outputFileName), chapters));
|
||||
File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".cue"), Cue.CreateContents(Path.GetFileName(outputFileName), downloadLicense.ChapterInfo));
|
||||
return !isCanceled;
|
||||
}
|
||||
|
||||
public bool Step6_CreateNfo()
|
||||
{
|
||||
File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".nfo"), NFO.CreateContents(AppName, aaxcTagLib, chapters));
|
||||
File.WriteAllText(PathLib.ReplaceExtension(outputFileName, ".nfo"), NFO.CreateContents(AppName, aaxcTagLib, downloadLicense.ChapterInfo));
|
||||
return !isCanceled;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
using Dinah.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AaxDecrypter
|
||||
{
|
||||
@ -13,6 +8,7 @@ namespace AaxDecrypter
|
||||
public string AudibleKey { get; }
|
||||
public string AudibleIV { get; }
|
||||
public string UserAgent { get; }
|
||||
public ChapterInfo ChapterInfo { get; set; }
|
||||
|
||||
public DownloadLicense(string downloadUrl, string audibleKey, string audibleIV, string userAgent)
|
||||
{
|
||||
|
||||
@ -69,24 +69,19 @@ namespace FileLiberator
|
||||
|
||||
var api = await InternalUtilities.AudibleApiActions.GetApiAsync(libraryBook.Account, libraryBook.Book.Locale);
|
||||
|
||||
var dlLic = await api.GetDownloadLicenseAsync(libraryBook.Book.AudibleProductId);
|
||||
var contentLic = await api.GetDownloadLicenseAsync(libraryBook.Book.AudibleProductId);
|
||||
|
||||
var aaxcDecryptDlLic = new DownloadLicense(dlLic.DownloadUrl, dlLic.AudibleKey, dlLic.AudibleIV, Resources.UserAgent);
|
||||
var aaxcDecryptDlLic = new DownloadLicense(contentLic.ContentMetadata?.ContentUrl?.OfflineUrl, contentLic.Voucher?.Key, contentLic.Voucher?.Iv, Resources.UserAgent);
|
||||
|
||||
if (Configuration.Instance.AllowLibationFixup)
|
||||
{
|
||||
var contentMetadata = await api.GetLibraryBookMetadataAsync(libraryBook.Book.AudibleProductId);
|
||||
var aaxcDecryptChapters = new ChapterInfo();
|
||||
aaxcDecryptDlLic.ChapterInfo = new ChapterInfo();
|
||||
|
||||
foreach (var chap in contentMetadata?.ChapterInfo?.Chapters)
|
||||
aaxcDecryptChapters.AddChapter(new Chapter(chap.Title, chap.StartOffsetMs, chap.LengthMs));
|
||||
foreach (var chap in contentLic.ContentMetadata?.ChapterInfo?.Chapters)
|
||||
aaxcDecryptDlLic.ChapterInfo.AddChapter(new Chapter(chap.Title, chap.StartOffsetMs, chap.LengthMs));
|
||||
}
|
||||
|
||||
aaxcDownloader = AaxcDownloadConverter.Create(destinationDir, aaxcDecryptDlLic, aaxcDecryptChapters);
|
||||
}
|
||||
else
|
||||
{
|
||||
aaxcDownloader = AaxcDownloadConverter.Create(destinationDir, aaxcDecryptDlLic);
|
||||
}
|
||||
aaxcDownloader = AaxcDownloadConverter.Create(destinationDir, aaxcDecryptDlLic);
|
||||
|
||||
aaxcDownloader.AppName = "Libation";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user