From 26da3077437325d9bac1737ca21f8787d5efe16e Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 21 Jun 2021 16:23:44 -0600 Subject: [PATCH 01/10] Hacked avformat-58 to ignore aac Scalable configurations error. --- .gitignore | 1 + AaxDecrypter/AaxDecrypter.csproj | 4 ++++ AaxDecrypter/AaxToM4bConverter.cs | 4 ++-- AaxDecrypter/DecryptLib/avformat-58.dll | Bin 9848320 -> 9848320 bytes LibationLauncher/LibationLauncher.csproj | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 09f749e1..43718433 100644 --- a/.gitignore +++ b/.gitignore @@ -333,3 +333,4 @@ ASALocalRun/ # manually ignored files /__TODO.txt /DataLayer/LibationContext.db +/AaxDecrypter/DecryptLib/avformat-58.dll.bak diff --git a/AaxDecrypter/AaxDecrypter.csproj b/AaxDecrypter/AaxDecrypter.csproj index daab451a..56b60933 100644 --- a/AaxDecrypter/AaxDecrypter.csproj +++ b/AaxDecrypter/AaxDecrypter.csproj @@ -4,6 +4,10 @@ net5.0 + + + + lib\taglib-sharp.dll diff --git a/AaxDecrypter/AaxToM4bConverter.cs b/AaxDecrypter/AaxToM4bConverter.cs index 4fbfc4de..b9237759 100644 --- a/AaxDecrypter/AaxToM4bConverter.cs +++ b/AaxDecrypter/AaxToM4bConverter.cs @@ -173,7 +173,7 @@ namespace AaxDecrypter { DecryptProgressUpdate?.Invoke(this, 0); - var tempRipFile = Path.Combine(outDir, "funny.mp4"); + var tempRipFile = Path.Combine(outDir, "funny.aac"); var fail = "WARNING-Decrypt failure. "; @@ -235,7 +235,7 @@ namespace AaxDecrypter + audible_iv + " -i " + "\"" + inputFileName + "\"" - + " -c:a copy -vn -sn -dn -y " + + " -c:a copy -vn -sn -dn -y -f adts " + "\"" + tempFileName + "\""; var info = new ProcessStartInfo diff --git a/AaxDecrypter/DecryptLib/avformat-58.dll b/AaxDecrypter/DecryptLib/avformat-58.dll index 18ccd0e7cf700326001957e705c8c84b5b513ca7..3716181424a8fd030c5b21775503826d4f4d56a8 100644 GIT binary patch delta 619 zcmW;I=Qq-47f|NL_w-A5PT&G$U- z4Sb=czu_Ua%YqTB`^^V}3xVJP!Z=7chlt=XksKk4qeOFz21ZWO0VGoZ~#%Tp)*BE|Nz+m$*y;S16>2Vy<$H>y&VVo7|$5GRmo-k}9eR zaGN{ag$Tctj)rA2!iU3#~k+jdnWd zb6)V0SBx>vYu@mdcf98VANj;*CYWT3X=eDsS3=A($2{No&JPy&$s)h_%@TiDW`$MO OSZ9OHoj`DF_un25hub#* delta 619 zcmWmASt1kw002-$mKLN4S(A{+P6!P}ix??nsf1LNt&&nBiO@paqrd*ThkJAYua9?u z7uwv52=Ti<7#X+H6BQP=90;xkf(JNAI1wBok|?5y;V?%y$}wVzBc9_VaDtO0lEf*J zNg)YrnPid88FDyFF6YQ2p90QP$OVch<{~AOQbsuyR8mDXHC&>WI_kMh1C2Cs zg#gX8aFuJc(#CaeaFbiKbDIu2`G45O9lE*8J$mS+kNfm9z#v0B;31C~<}o9TGR70e zdCD`MGr=S;c*zvg%rMIwuXxQH=6TBk?|9E5ANWX!B|fptXIA*aDr@3 QlP$LS#m=8VaQE-OeN%(j$p8QV diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index baa93b8a..bc9b948c 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.4.0.34 + 4.4.0.42 From c81788429b337ee37f90410605f26e4b7be57983 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 21 Jun 2021 16:29:28 -0600 Subject: [PATCH 02/10] Revert "Hacked avformat-58 to ignore aac Scalable configurations error." This reverts commit 26da3077437325d9bac1737ca21f8787d5efe16e. --- .gitignore | 1 - AaxDecrypter/AaxDecrypter.csproj | 4 ---- AaxDecrypter/AaxToM4bConverter.cs | 4 ++-- AaxDecrypter/DecryptLib/avformat-58.dll | Bin 9848320 -> 9848320 bytes LibationLauncher/LibationLauncher.csproj | 2 +- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 43718433..09f749e1 100644 --- a/.gitignore +++ b/.gitignore @@ -333,4 +333,3 @@ ASALocalRun/ # manually ignored files /__TODO.txt /DataLayer/LibationContext.db -/AaxDecrypter/DecryptLib/avformat-58.dll.bak diff --git a/AaxDecrypter/AaxDecrypter.csproj b/AaxDecrypter/AaxDecrypter.csproj index 56b60933..daab451a 100644 --- a/AaxDecrypter/AaxDecrypter.csproj +++ b/AaxDecrypter/AaxDecrypter.csproj @@ -4,10 +4,6 @@ net5.0 - - - - lib\taglib-sharp.dll diff --git a/AaxDecrypter/AaxToM4bConverter.cs b/AaxDecrypter/AaxToM4bConverter.cs index b9237759..4fbfc4de 100644 --- a/AaxDecrypter/AaxToM4bConverter.cs +++ b/AaxDecrypter/AaxToM4bConverter.cs @@ -173,7 +173,7 @@ namespace AaxDecrypter { DecryptProgressUpdate?.Invoke(this, 0); - var tempRipFile = Path.Combine(outDir, "funny.aac"); + var tempRipFile = Path.Combine(outDir, "funny.mp4"); var fail = "WARNING-Decrypt failure. "; @@ -235,7 +235,7 @@ namespace AaxDecrypter + audible_iv + " -i " + "\"" + inputFileName + "\"" - + " -c:a copy -vn -sn -dn -y -f adts " + + " -c:a copy -vn -sn -dn -y " + "\"" + tempFileName + "\""; var info = new ProcessStartInfo diff --git a/AaxDecrypter/DecryptLib/avformat-58.dll b/AaxDecrypter/DecryptLib/avformat-58.dll index 3716181424a8fd030c5b21775503826d4f4d56a8..18ccd0e7cf700326001957e705c8c84b5b513ca7 100644 GIT binary patch delta 619 zcmWmASt1kw002-$mKLN4S(A{+P6!P}ix??nsf1LNt&&nBiO@paqrd*ThkJAYua9?u z7uwv52=Ti<7#X+H6BQP=90;xkf(JNAI1wBok|?5y;V?%y$}wVzBc9_VaDtO0lEf*J zNg)YrnPid88FDyFF6YQ2p90QP$OVch<{~AOQbsuyR8mDXHC&>WI_kMh1C2Cs zg#gX8aFuJc(#CaeaFbiKbDIu2`G45O9lE*8J$mS+kNfm9z#v0B;31C~<}o9TGR70e zdCD`MGr=S;c*zvg%rMIwuXxQH=6TBk?|9E5ANWX!B|fptXIA*aDr@3 QlP$LS#m=8VaQE-OeN%(j$p8QV delta 619 zcmW;I=Qq-47f|NL_w-A5PT&G$U- z4Sb=czu_Ua%YqTB`^^V}3xVJP!Z=7chlt=XksKk4qeOFz21ZWO0VGoZ~#%Tp)*BE|Nz+m$*y;S16>2Vy<$H>y&VVo7|$5GRmo-k}9eR zaGN{ag$Tctj)rA2!iU3#~k+jdnWd zb6)V0SBx>vYu@mdcf98VANj;*CYWT3X=eDsS3=A($2{No&JPy&$s)h_%@TiDW`$MO OSZ9OHoj`DF_un25hub#* diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index bc9b948c..baa93b8a 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.4.0.42 + 4.4.0.34 From 344e6756346fc3c94d4b16900d7751131405fd53 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 21 Jun 2021 16:38:02 -0600 Subject: [PATCH 03/10] Hacked avformat-58.dll to ignore aac Scalable configurations flag. --- AaxDecrypter/AaxToM4bConverter.cs | 2 +- AaxDecrypter/DecryptLib/avformat-58.dll | Bin 9848320 -> 9848320 bytes LibationLauncher/LibationLauncher.csproj | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AaxDecrypter/AaxToM4bConverter.cs b/AaxDecrypter/AaxToM4bConverter.cs index 4fbfc4de..3f43b5c1 100644 --- a/AaxDecrypter/AaxToM4bConverter.cs +++ b/AaxDecrypter/AaxToM4bConverter.cs @@ -173,7 +173,7 @@ namespace AaxDecrypter { DecryptProgressUpdate?.Invoke(this, 0); - var tempRipFile = Path.Combine(outDir, "funny.mp4"); + var tempRipFile = Path.Combine(outDir, "funny.aac"); var fail = "WARNING-Decrypt failure. "; diff --git a/AaxDecrypter/DecryptLib/avformat-58.dll b/AaxDecrypter/DecryptLib/avformat-58.dll index 18ccd0e7cf700326001957e705c8c84b5b513ca7..3716181424a8fd030c5b21775503826d4f4d56a8 100644 GIT binary patch delta 619 zcmW;I=Qq-47f|NL_w-A5PT&G$U- z4Sb=czu_Ua%YqTB`^^V}3xVJP!Z=7chlt=XksKk4qeOFz21ZWO0VGoZ~#%Tp)*BE|Nz+m$*y;S16>2Vy<$H>y&VVo7|$5GRmo-k}9eR zaGN{ag$Tctj)rA2!iU3#~k+jdnWd zb6)V0SBx>vYu@mdcf98VANj;*CYWT3X=eDsS3=A($2{No&JPy&$s)h_%@TiDW`$MO OSZ9OHoj`DF_un25hub#* delta 619 zcmWmASt1kw002-$mKLN4S(A{+P6!P}ix??nsf1LNt&&nBiO@paqrd*ThkJAYua9?u z7uwv52=Ti<7#X+H6BQP=90;xkf(JNAI1wBok|?5y;V?%y$}wVzBc9_VaDtO0lEf*J zNg)YrnPid88FDyFF6YQ2p90QP$OVch<{~AOQbsuyR8mDXHC&>WI_kMh1C2Cs zg#gX8aFuJc(#CaeaFbiKbDIu2`G45O9lE*8J$mS+kNfm9z#v0B;31C~<}o9TGR70e zdCD`MGr=S;c*zvg%rMIwuXxQH=6TBk?|9E5ANWX!B|fptXIA*aDr@3 QlP$LS#m=8VaQE-OeN%(j$p8QV diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index ab60526f..10ffa01a 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.4.0.35 + 4.4.0.37 From 0034d5192119990aa9ea057eb92d2f1c700ffcac Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 14:59:37 -0600 Subject: [PATCH 04/10] Add migration to re-register device fore new Identity properties. --- LibationLauncher/Program.cs | 42 ++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/LibationLauncher/Program.cs b/LibationLauncher/Program.cs index dc53641f..61935d9a 100644 --- a/LibationLauncher/Program.cs +++ b/LibationLauncher/Program.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Windows.Forms; using AudibleApi; +using AudibleApi.Authorization; using FileManager; using InternalUtilities; using LibationWinForms; @@ -29,6 +30,7 @@ namespace LibationLauncher migrate_to_v4_0_0(); migrate_to_v4_0_3(); // add setting for whether to delete/retain aax + migrate_to_v5_x_x(); ensureLoggingConfig(); ensureSerilogConfig(); @@ -194,7 +196,7 @@ namespace LibationLauncher var jLocale = jObj.Property("LocaleCountryCode"); var jDecryptKey = jObj.Property("DecryptKey"); - + jDecryptKey?.Remove(); jLocale?.Remove(); @@ -220,14 +222,48 @@ namespace LibationLauncher if (jRetainAaxFiles is null) { jObj.Add("RetainAaxFiles", false); - + var newContents = jObj.ToString(Formatting.Indented); File.WriteAllText(Configuration.Instance.SettingsFilePath, newContents); } } #endregion - private static string defaultLoggingLevel { get; } = "Information"; + #region migrate_to_v5_x_x re-gegister device if device info not in settings + private static void migrate_to_v5_x_x() + { + if (!File.Exists(AudibleApiStorage.AccountsSettingsFile)) + return; + + var accountsPersister = AudibleApiStorage.GetAccountsSettingsPersister(); + + foreach (var account in accountsPersister.AccountsSettings.Accounts) + { + var identity = account.IdentityTokens; + + if (!string.IsNullOrWhiteSpace(identity.DeviceType) && + !string.IsNullOrWhiteSpace(identity.DeviceType) && + !string.IsNullOrWhiteSpace(identity.DeviceType)) + break; + + var authorize = new AudibleApi.Authorization.Authorize(identity?.Locale); + + try + { + authorize.DeregisterAsync(identity.ExistingAccessToken, identity.Cookies.ToKeyValuePair()).GetAwaiter().GetResult(); + identity.Invalidate(); + + var api = AudibleApiActions.GetApiAsync(new LibationWinForms.Login.WinformResponder(account), account).GetAwaiter().GetResult(); + } + catch + { + // Don't care if it fails + } + } + } + #endregion + + private static string defaultLoggingLevel { get; } = "Information"; private static void ensureLoggingConfig() { var config = Configuration.Instance; From dbcd124c1dcceef3842830a23ff87dbf22e329cd Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 15:15:08 -0600 Subject: [PATCH 05/10] Match version --- LibationLauncher/LibationLauncher.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 10ffa01a..cd9acb48 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.4.0.37 + 4.4.0.63 From bb3baa6ce09442df0421669ccf496e13c2a2cb00 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 16:36:23 -0600 Subject: [PATCH 06/10] Added explanation of avformat-58 hack. --- AaxDecrypter/AaxToM4bConverter.cs | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/AaxDecrypter/AaxToM4bConverter.cs b/AaxDecrypter/AaxToM4bConverter.cs index 3f43b5c1..fca91bad 100644 --- a/AaxDecrypter/AaxToM4bConverter.cs +++ b/AaxDecrypter/AaxToM4bConverter.cs @@ -227,6 +227,80 @@ namespace AaxDecrypter private int ngDecrypt(object tempFileNameObj) { + #region avformat-58.dll HACK EXPLANATION + /* avformat-58.dll HACK EXPLANATION + * + * FFMPEG refused to copy the aac stream from AAXC files with 44kHz sample rates + * with error "Scalable configurations are not allowed in ADTS". The adts encoder + * can be found on github at: + * https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/adtsenc.c + * + * adtsenc detects scalable aac by a flag in the aac metadata and throws an error if + * it is set. It appears that all aaxc files contain aac streams that can be written + * to adts, but either the codec is parsing the header incorrectly or the aaxc + * header is incorrect. + * + * As a workaround, i've modified avformat-58.dll to allow adtsenc to ignore the + * scalable flag and continue. To modify: + * + * Open ffmpeg.exe in x64dbg (https://x64dbg.com) + * + * Navigate to the avformat module and search for the error string "Scalable + * configurations are not allowed in ADTS". (00007FFE16AA5899 in example below). + * + * 00007FFE16AA587B | 4C:8D05 DE5E6900 | lea r8,qword ptr ds:[7FFE1713B760] | 00007FFE1713B760:"960/120 MDCT window is not allowed in ADTS\n" + * 00007FFE16AA5882 | BA 10000000 | mov edx,10 | + * 00007FFE16AA5887 | 4C:89F1 | mov rcx,r14 | + * 00007FFE16AA588A | E8 697A1900 | call | + * 00007FFE16AA588F | B8 B7B1BBBE | mov eax,BEBBB1B7 | + * 00007FFE16AA5894 | E9 D5F8FFFF | jmp avformat-58.7FFE16AA516E | + * 00007FFE16AA5899 | 4C:8D05 F05E6900 | lea r8,qword ptr ds:[7FFE1713B790] | 00007FFE1713B790:"Scalable configurations are not allowed in ADTS\n" + * 00007FFE16AA58A0 | BA 10000000 | mov edx,10 | + * 00007FFE16AA58A5 | 4C:89F1 | mov rcx,r14 | + * 00007FFE16AA58A8 | E8 4B7A1900 | call | + * 00007FFE16AA58AD | B8 B7B1BBBE | mov eax,BEBBB1B7 | + * 00007FFE16AA58B2 | E9 B7F8FFFF | jmp avformat-58.7FFE16AA516E | + * 00007FFE16AA58B7 | 4C:8D05 4A5E6900 | lea r8,qword ptr ds:[7FFE1713B708] | 00007FFE1713B708:"MPEG-4 AOT %d is not allowed in ADTS\n" + * 00007FFE16AA58BE | BA 10000000 | mov edx,10 | + * 00007FFE16AA58C3 | 4C:89F1 | mov rcx,r14 | + * 00007FFE16AA58C6 | E8 2D7A1900 | call | + * 00007FFE16AA58CB | B8 B7B1BBBE | mov eax,BEBBB1B7 | + * 00007FFE16AA58D0 | E9 99F8FFFF | jmp avformat-58.7FFE16AA516E | + * 00007FFE16AA58D5 | 4C:8D05 EC5E6900 | lea r8,qword ptr ds:[7FFE1713B7C8] | 00007FFE1713B7C8:"Extension flag is not allowed in ADTS\n" + * 00007FFE16AA58DC | BA 10000000 | mov edx,10 | + * 00007FFE16AA58E1 | 4C:89F1 | mov rcx,r14 | + * 00007FFE16AA58E4 | E8 0F7A1900 | call | + * 00007FFE16AA58E9 | B8 B7B1BBBE | mov eax,BEBBB1B7 | + * 00007FFE16AA58EE | E9 7BF8FFFF | jmp avformat-58.7FFE16AA516E | + * 00007FFE16AA58F3 | 4C:8D05 365E6900 | lea r8,qword ptr ds:[7FFE1713B730] | 00007FFE1713B730:"Escape sample rate index illegal in ADTS\n" + * 00007FFE16AA58FA | BA 10000000 | mov edx,10 | + * 00007FFE16AA58FF | 4C:89F1 | mov rcx,r14 | + * 00007FFE16AA5902 | E8 F1791900 | call | + * 00007FFE16AA5907 | B8 B7B1BBBE | mov eax,BEBBB1B7 | + * 00007FFE16AA590C | E9 5DF8FFFF | jmp avformat-58.7FFE16AA516E | + * + * Select the instruction that loads the error string's address, and search for all + * references. You should only find one referance, a conditional jump + * (00007FFE16AA513C example below). + * + * 00007FFE16AA511D | 89C2 | mov edx,eax | + * 00007FFE16AA511F | 89C1 | mov ecx,eax | + * 00007FFE16AA5121 | 83C0 01 | add eax,1 | + * 00007FFE16AA5124 | C1EA 03 | shr edx,3 | + * 00007FFE16AA5127 | 83E1 07 | and ecx,7 | + * 00007FFE16AA512A | 41:8B1414 | mov edx,dword ptr ds:[r12+rdx] | + * 00007FFE16AA512E | 0FCA | bswap edx | + * 00007FFE16AA5130 | D3E2 | shl edx,cl | + * 00007FFE16AA5132 | C1EA FF | shr edx,FF | + * 00007FFE16AA5135 | 39F8 | cmp eax,edi | + * 00007FFE16AA5137 | 0F47C7 | cmova eax,edi | + * 00007FFE16AA513A | 85D2 | test edx,edx | + * 00007FFE16AA513C | 0F85 57070000 | jne avformat-58.7FFE16AA5899 | + * + * Edit that jump with six nop instructions and save the patched assembly. + */ + #endregion + var tempFileName = tempFileNameObj as string; string args = "-audible_key " From e13dc2a48a8bb715f4c1eacc756431a21d22a671 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 16:48:43 -0600 Subject: [PATCH 07/10] Fixed migration logic. --- LibationLauncher/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibationLauncher/Program.cs b/LibationLauncher/Program.cs index 61935d9a..42913623 100644 --- a/LibationLauncher/Program.cs +++ b/LibationLauncher/Program.cs @@ -244,7 +244,7 @@ namespace LibationLauncher if (!string.IsNullOrWhiteSpace(identity.DeviceType) && !string.IsNullOrWhiteSpace(identity.DeviceType) && !string.IsNullOrWhiteSpace(identity.DeviceType)) - break; + continue; var authorize = new AudibleApi.Authorization.Authorize(identity?.Locale); From 8d70d2a95f4c6e10b0c1d97314cede9759bf9b34 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 16:53:02 -0600 Subject: [PATCH 08/10] Fixed migration logic. --- LibationLauncher/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibationLauncher/Program.cs b/LibationLauncher/Program.cs index 42913623..3f2d9fe7 100644 --- a/LibationLauncher/Program.cs +++ b/LibationLauncher/Program.cs @@ -242,8 +242,8 @@ namespace LibationLauncher var identity = account.IdentityTokens; if (!string.IsNullOrWhiteSpace(identity.DeviceType) && - !string.IsNullOrWhiteSpace(identity.DeviceType) && - !string.IsNullOrWhiteSpace(identity.DeviceType)) + !string.IsNullOrWhiteSpace(identity.DeviceSerialNumber) && + !string.IsNullOrWhiteSpace(identity.AmazonAccountId)) continue; var authorize = new AudibleApi.Authorization.Authorize(identity?.Locale); From 919175cc100cee646989cb547a59245781057c45 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 16:55:56 -0600 Subject: [PATCH 09/10] Fixed migration logic. --- LibationLauncher/Program.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/LibationLauncher/Program.cs b/LibationLauncher/Program.cs index 3f2d9fe7..f63ca021 100644 --- a/LibationLauncher/Program.cs +++ b/LibationLauncher/Program.cs @@ -237,16 +237,19 @@ namespace LibationLauncher var accountsPersister = AudibleApiStorage.GetAccountsSettingsPersister(); - foreach (var account in accountsPersister.AccountsSettings.Accounts) + foreach (var account in accountsPersister?.AccountsSettings?.Accounts) { - var identity = account.IdentityTokens; + var identity = account?.IdentityTokens; + + if (identity is null) + continue; if (!string.IsNullOrWhiteSpace(identity.DeviceType) && !string.IsNullOrWhiteSpace(identity.DeviceSerialNumber) && !string.IsNullOrWhiteSpace(identity.AmazonAccountId)) continue; - var authorize = new AudibleApi.Authorization.Authorize(identity?.Locale); + var authorize = new AudibleApi.Authorization.Authorize(identity.Locale); try { From d619c82fd8c3c2049c22d7f2c75e386e8ded5d6d Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 22 Jun 2021 17:30:48 -0600 Subject: [PATCH 10/10] Added progress bar to Chapterize step. --- AaxDecrypter/AaxToM4bConverter.cs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/AaxDecrypter/AaxToM4bConverter.cs b/AaxDecrypter/AaxToM4bConverter.cs index fca91bad..54000c16 100644 --- a/AaxDecrypter/AaxToM4bConverter.cs +++ b/AaxDecrypter/AaxToM4bConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; @@ -207,8 +206,8 @@ namespace AaxDecrypter Console.WriteLine($"Decrypting with key={audible_key}, iv={audible_iv}"); var returnCode = 100; - var thread = new Thread((b) => returnCode = ngDecrypt(b)); - thread.Start(tempRipFile); + var thread = new Thread(_ => returnCode = ngDecrypt(tempRipFile)); + thread.Start(); double fileLen = new FileInfo(inputFileName).Length; while (thread.IsAlive && returnCode == 100) @@ -225,7 +224,7 @@ namespace AaxDecrypter return returnCode; } - private int ngDecrypt(object tempFileNameObj) + private int ngDecrypt(string tempFileName) { #region avformat-58.dll HACK EXPLANATION /* avformat-58.dll HACK EXPLANATION @@ -301,8 +300,6 @@ namespace AaxDecrypter */ #endregion - var tempFileName = tempFileNameObj as string; - string args = "-audible_key " + audible_key + " -audible_iv " @@ -350,11 +347,29 @@ namespace AaxDecrypter FileName = DecryptSupportLibraries.ffmpegPath, Arguments = "-y -i \"" + mp4_file + "\" -f ffmetadata -i \"" + ff_txt_file + "\" -map_metadata 1 -bsf:a aac_adtstoasc -c:a copy" + str1 + " -map 0 \"" + tempChapsPath + "\"" }; - tagAndChapterInfo.RunHidden(); + + var thread = new Thread(_ => tagAndChapterInfo.RunHidden()); + thread.Start(); + + double fileLen = new FileInfo(mp4_file).Length; + + while (thread.IsAlive) + { + Thread.Sleep(500); + if (File.Exists(tempChapsPath)) + { + double tempLen = new FileInfo(tempChapsPath).Length; + var percentProgress = tempLen / fileLen * 100.0; + DecryptProgressUpdate?.Invoke(this, (int)percentProgress); + } + } + + DecryptProgressUpdate?.Invoke(this, 0); return true; } + public bool Step4_InsertCoverArt() { // save cover image as temp file