Progress toward purging static current locale
This commit is contained in:
parent
901572e7bb
commit
82318ffab7
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AudibleApi;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
using Dinah.Core.ErrorHandling;
|
using Dinah.Core.ErrorHandling;
|
||||||
@ -42,7 +43,8 @@ namespace FileLiberator
|
|||||||
|
|
||||||
private async Task<string> downloadBookAsync(LibraryBook libraryBook, string tempAaxFilename)
|
private async Task<string> 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(
|
var actualFilePath = await PerformDownloadAsync(
|
||||||
tempAaxFilename,
|
tempAaxFilename,
|
||||||
|
|||||||
@ -13,11 +13,11 @@ namespace InternalUtilities
|
|||||||
public static class AudibleApiActions
|
public static class AudibleApiActions
|
||||||
{
|
{
|
||||||
/// <summary>USE THIS from within Libation. It wraps the call with correct JSONPath</summary>
|
/// <summary>USE THIS from within Libation. It wraps the call with correct JSONPath</summary>
|
||||||
public static async Task<Api> GetApiAsync(ILoginCallback loginCallback = null)
|
public static async Task<Api> GetApiAsync(Locale locale, ILoginCallback loginCallback = null)
|
||||||
{
|
{
|
||||||
Localization.SetLocale(Configuration.Instance.LocaleCountryCode);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>USE THIS from within Libation. It wraps the call with correct JSONPath</summary>
|
/// <summary>USE THIS from within Libation. It wraps the call with correct JSONPath</summary>
|
||||||
@ -25,7 +25,7 @@ namespace InternalUtilities
|
|||||||
{
|
{
|
||||||
Localization.SetLocale(Configuration.Instance.LocaleCountryCode);
|
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; }
|
private static AsyncRetryPolicy policy { get; }
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>3.1.12.152</Version>
|
<Version>3.1.12.160</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using AudibleApi;
|
||||||
using FileManager;
|
using FileManager;
|
||||||
using InternalUtilities;
|
using InternalUtilities;
|
||||||
using LibationWinForms;
|
using LibationWinForms;
|
||||||
@ -137,10 +138,16 @@ namespace LibationLauncher
|
|||||||
|
|
||||||
private static Account addAccountToNewAccountFile()
|
private static Account addAccountToNewAccountFile()
|
||||||
{
|
{
|
||||||
AudibleApi.Localization.SetLocale(Configuration.Instance.LocaleCountryCode);
|
// get locale from settings file
|
||||||
var api = AudibleApi.EzApiCreator.GetApiAsync(AccountsSettingsFileLegacy30).GetAwaiter().GetResult();
|
var settingsContents = File.ReadAllText(Configuration.Instance.SettingsFilePath);
|
||||||
|
var jObj = JObject.Parse(settingsContents);
|
||||||
|
var jLocale = jObj.Property("LocaleCountryCode");
|
||||||
|
var localeName = jLocale.Value<string>();
|
||||||
|
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 email = api.GetEmailAsync().GetAwaiter().GetResult();
|
||||||
var locale = api.GetLocaleAsync(AudibleApi.CustomerOptions.All).GetAwaiter().GetResult();
|
|
||||||
|
|
||||||
// identity has likely been updated above. re-get contents
|
// identity has likely been updated above. re-get contents
|
||||||
var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);
|
var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user