diff --git a/FileLiberator/UNTESTED/DownloadBook.cs b/FileLiberator/UNTESTED/DownloadBook.cs index e571ac97..b4b18e7a 100644 --- a/FileLiberator/UNTESTED/DownloadBook.cs +++ b/FileLiberator/UNTESTED/DownloadBook.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Threading.Tasks; +using AudibleApi; using DataLayer; using Dinah.Core; using Dinah.Core.ErrorHandling; @@ -42,7 +43,8 @@ namespace FileLiberator private async Task downloadBookAsync(LibraryBook libraryBook, string tempAaxFilename) { - var api = await AudibleApiActions.GetApiAsync(); + var locale = Localization.Get(libraryBook.Book.Locale); + var api = await AudibleApiActions.GetApiAsync(locale); var actualFilePath = await PerformDownloadAsync( tempAaxFilename, diff --git a/InternalUtilities/UNTESTED/AudibleApiActions.cs b/InternalUtilities/UNTESTED/AudibleApiActions.cs index 78200864..e781b231 100644 --- a/InternalUtilities/UNTESTED/AudibleApiActions.cs +++ b/InternalUtilities/UNTESTED/AudibleApiActions.cs @@ -13,11 +13,11 @@ namespace InternalUtilities public static class AudibleApiActions { /// USE THIS from within Libation. It wraps the call with correct JSONPath - public static async Task GetApiAsync(ILoginCallback loginCallback = null) + public static async Task GetApiAsync(Locale locale, ILoginCallback loginCallback = null) { Localization.SetLocale(Configuration.Instance.LocaleCountryCode); - return await EzApiCreator.GetApiAsync(AudibleApiStorage.AccountsSettingsFile, AudibleApiStorage.TEST_GetFirstIdentityTokensJsonPath(), loginCallback); + return await EzApiCreator.GetApiAsync(locale, AudibleApiStorage.AccountsSettingsFile, AudibleApiStorage.TEST_GetFirstIdentityTokensJsonPath(), loginCallback); } /// USE THIS from within Libation. It wraps the call with correct JSONPath @@ -25,7 +25,7 @@ namespace InternalUtilities { Localization.SetLocale(Configuration.Instance.LocaleCountryCode); - return await EzApiCreator.GetApiAsync(AudibleApiStorage.AccountsSettingsFile, account.GetIdentityTokensJsonPath(), loginCallback); + return await EzApiCreator.GetApiAsync(account.Locale, AudibleApiStorage.AccountsSettingsFile, account.GetIdentityTokensJsonPath(), loginCallback); } private static AsyncRetryPolicy policy { get; } diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index b6366e05..b814ea93 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.12.152 + 3.1.12.160 diff --git a/LibationLauncher/UNTESTED/Program.cs b/LibationLauncher/UNTESTED/Program.cs index 39db7676..bb08e5ba 100644 --- a/LibationLauncher/UNTESTED/Program.cs +++ b/LibationLauncher/UNTESTED/Program.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Linq; using System.Windows.Forms; +using AudibleApi; using FileManager; using InternalUtilities; using LibationWinForms; @@ -137,10 +138,16 @@ namespace LibationLauncher private static Account addAccountToNewAccountFile() { - AudibleApi.Localization.SetLocale(Configuration.Instance.LocaleCountryCode); - var api = AudibleApi.EzApiCreator.GetApiAsync(AccountsSettingsFileLegacy30).GetAwaiter().GetResult(); + // get locale from settings file + var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath); + var jObj = JObject.Parse(settingsContents); + var jLocale = jObj.Property("LocaleCountryCode"); + var localeName = jLocale.Value(); + var locale = Localization.Get(localeName); + + Localization.SetLocale(Configuration.Instance.LocaleCountryCode); + var api = EzApiCreator.GetApiAsync(locale, AccountsSettingsFileLegacy30).GetAwaiter().GetResult(); var email = api.GetEmailAsync().GetAwaiter().GetResult(); - var locale = api.GetLocaleAsync(AudibleApi.CustomerOptions.All).GetAwaiter().GetResult(); // identity has likely been updated above. re-get contents var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);