示例#1
0
        private async Task <string> aaxToM4bConverterDecrypt(string aaxFilename, LibraryBook libraryBook)
        {
            DecryptBegin?.Invoke(this, $"Begin decrypting {aaxFilename}");

            try
            {
                using var persister = AudibleApiStorage.GetAccountsSettingsPersister();

                var account = persister
                              .AccountsSettings
                              .GetAccount(libraryBook.Account, libraryBook.Book.Locale);

                var converter = await AaxToM4bConverter.CreateAsync(aaxFilename, account.DecryptKey);

                converter.AppName = "Libation";

                TitleDiscovered?.Invoke(this, converter.tags.title);
                AuthorsDiscovered?.Invoke(this, converter.tags.author);
                NarratorsDiscovered?.Invoke(this, converter.tags.narrator);
                CoverImageFilepathDiscovered?.Invoke(this, converter.coverBytes);

                // override default which was set in CreateAsync
                var proposedOutputFile = Path.Combine(AudibleFileStorage.DecryptInProgress, $"[{libraryBook.Book.AudibleProductId}].m4b");
                converter.SetOutputFilename(proposedOutputFile);
                converter.DecryptProgressUpdate += (s, progress) => UpdateProgress?.Invoke(this, progress);

                // REAL WORK DONE HERE
                var success = await Task.Run(() => converter.Run());

                // decrypt failed
                if (!success)
                {
                    return(null);
                }

                account.DecryptKey = converter.decryptKey;

                return(converter.outputFileName);
            }
            finally
            {
                DecryptCompleted?.Invoke(this, $"Completed decrypting {aaxFilename}");
            }
        }
示例#2
0
 private void aaxcDownloader_RetrievedTags(object sender, AAXClean.AppleTags e)
 {
     TitleDiscovered?.Invoke(this, e.TitleSansUnabridged);
     AuthorsDiscovered?.Invoke(this, e.FirstAuthor ?? "[unknown]");
     NarratorsDiscovered?.Invoke(this, e.Narrator ?? "[unknown]");
 }
示例#3
0
 protected void OnTitleDiscovered(string title)
 {
     Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(TitleDiscovered), Title = title });
     TitleDiscovered?.Invoke(this, title);
 }