Add audible locale setting.

Rename DomainServices => ScrapingDomainServices
This commit is contained in:
Robert McRackan 2019-10-21 12:57:37 -04:00
parent fbc9824f12
commit 410d1a9621
28 changed files with 698 additions and 371 deletions

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Dinah.Core\Dinah.Core\Dinah.Core.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,19 @@
using System;
using System.Threading.Tasks;
namespace AudibleApiDomainService
{
public class AudibleApiLibationClient
{
private Settings settings;
public AudibleApiLibationClient(Settings settings)
=> this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
public async Task ImportLibraryAsync()
{
// call api
// translate to DTOs
// update database
}
}
}

View File

@ -0,0 +1,205 @@
//using System;
//using System.IO;
//using System.Net.Http;
//using System.Threading.Tasks;
//using AudibleApi;
//using AudibleApi.Authentication;
//using AudibleApi.Authorization;
//using Dinah.Core.Net.Http;
//using Newtonsoft.Json;
//namespace AudibleApiDomainService
//{
// public class AudibleApiClient
// {
// #region initialize api
// public const string APP_SETTINGS = "appsettings.json";
// private Api _api;
// private static ClientSettings settings;
// private AudibleApiClient() { }
// public async static Task<AudibleApiClient> CreateClientAsync()
// {
// settings = ClientSettings.FromFile(APP_SETTINGS);
// restoreLocale();
// Api api;
// try
// {
// api = await EzApiCreator.GetApiAsync(settings.IdentityFilePath);
// }
// catch
// {
// var inMemoryIdentity = await loginAsync(email, password);
// api = await EzApiCreator.GetApiAsync(settings.IdentityFilePath, inMemoryIdentity);
// }
// return new AudibleApiClient { _api = api };
// }
// private static void restoreLocale()
// {
// if (settings.LocaleCountryCode != null)
// Localization.SetLocale(settings.LocaleCountryCode);
// }
// // LOGIN PATTERN
// // - Start with Authenticate. Submit email + pw
// // - Each step in the login process will return a LoginResult
// // - Each result which has required user input has a SubmitAsync method
// // - The final LoginComplete result returns "Identity" -- in-memory authorization items
// private static async Task<IIdentity> loginAsync(string email, string pw)
// {
// var login = new Authenticate();
// var loginResult = await login.SubmitCredentialsAsync(email, pw);
// while (true)
// {
// switch (loginResult)
// {
// case CredentialsPage credentialsPage:
// Console.WriteLine("Email:");
// var emailInput = Console.ReadLine();
// Console.WriteLine("Password:");
// var pwInput = Dinah.Core.ConsoleLib.ConsoleExt.ReadPassword();
// loginResult = await credentialsPage.SubmitAsync(emailInput, pwInput);
// break;
// case CaptchaPage captchaResult:
// var imageBytes = await downloadImageAsync(captchaResult.CaptchaImage);
// var guess = getUserCaptchaGuess(imageBytes);
// loginResult = await captchaResult.SubmitAsync(guess);
// break;
// case TwoFactorAuthenticationPage _2fa:
// Console.WriteLine("Two-Step Verification code:");
// var _2faCode = Console.ReadLine();
// loginResult = await _2fa.SubmitAsync(_2faCode);
// break;
// case LoginComplete final:
// return final.Identity;
// default:
// throw new Exception("Unknown LoginResult");
// }
// }
// }
// private static async Task<byte[]> downloadImageAsync(Uri imageUri)
// {
// using var client = new HttpClient();
// using var contentStream = await client.GetStreamAsync(imageUri);
// using var localStream = new MemoryStream();
// await contentStream.CopyToAsync(localStream);
// return localStream.ToArray();
// }
// private static string getUserCaptchaGuess(byte[] captchaImage)
// {
// var tempFileName = Path.Combine(Path.GetTempPath(), "audible_api_captcha_" + Guid.NewGuid() + ".jpg");
// try
// {
// File.WriteAllBytes(tempFileName, captchaImage);
// var processStartInfo = new System.Diagnostics.ProcessStartInfo
// {
// Verb = string.Empty,
// UseShellExecute = true,
// CreateNoWindow = true,
// FileName = tempFileName
// };
// System.Diagnostics.Process.Start(processStartInfo);
// Console.WriteLine("CAPTCHA answer: ");
// var guess = Console.ReadLine();
// return guess;
// }
// finally
// {
// if (File.Exists(tempFileName))
// File.Delete(tempFileName);
// }
// }
// #endregion
// #region api call examples
// // Mimi's Adventure (3m)
// public const string TINY_BOOK_ASIN = "B079DZ8YMP";
// // Harry Potter 1 (8h 33m)
// public const string MEDIUM_BOOK_ASIN = "B017V4IM1G";
// // Sherlock Holmes (62h 52m)
// public const string HUGE_BOOK_ASIN = "B06WLMWF2S";
// public Task PrintLibraryAsync() => wrapCallAsync(printLibraryAsync);
// private async Task printLibraryAsync()
// {
// // test ad hoc api calls
// string url;
// string allGroups;
// url
// = "/1.0/library"
// + "?purchaseAfterDate=01/01/1970&page=23";
// url = "/1.0/library/" +
// //TINY_BOOK_ASIN
// MEDIUM_BOOK_ASIN
// //HUGE_BOOK_ASIN
// ;
// url += url.Contains("?") ? "&" : "?";
// //allGroups = "response_groups=badge_types,category_ladders,claim_code_url,contributors,is_downloaded,is_returnable,media,origin_asin,pdf_url,percent_complete,price,product_attrs,product_desc,product_extended_attrs,product_plan_details,product_plans,provided_review,rating,relationships,review_attrs,reviews,sample,series,sku";
// allGroups = "response_groups=series,category_ladders,contributors";
// url += allGroups;
// var responseMsg = await _api.AdHocAuthenticatedGetAsync(url);
// var jObj = await responseMsg.Content.ReadAsJObjectAsync();
// var str = jObj.ToString(Formatting.Indented);
// Console.WriteLine(str);
// }
// public Task DownloadBookAsync() => wrapCallAsync(downloadBookAsync);
// private async Task downloadBookAsync()
// {
// using var progressBar = new Dinah.Core.ConsoleLib.ProgressBar();
// var progress = new Progress<DownloadProgress>();
// progress.ProgressChanged += (_, e) => progressBar.Report(Math.Round((double)(100 * e.BytesReceived) / e.TotalFileSize.Value) / 100);
// Console.Write("Download book");
// var finalFile = await _api.DownloadAaxWorkaroundAsync(TINY_BOOK_ASIN, "downloadExample.xyz", progress);
// Console.WriteLine(" Done!");
// Console.WriteLine("final file: " + Path.GetFullPath(finalFile));
// // benefit of this small delay:
// // - if you try to delete a file too soon after it's created, the OS isn't done with the creation and you can get an unexpected error
// // - give progressBar's internal timer time to finish. if timer is disposed before the final message is processed, "100%" will never get a chance to be displayed
// await Task.Delay(100);
// File.Delete(finalFile);
// }
// private async Task wrapCallAsync(Func<Task> fn)
// {
// try
// {
// await fn();
// }
// catch (AudibleApiException aex)
// {
// Console.WriteLine("ERROR:");
// Console.WriteLine(aex.Message);
// Console.WriteLine(aex.JsonMessage.ToString());
// Console.WriteLine(aex.RequestUri.ToString());
// }
// }
// #endregion
// }
//}

View File

@ -0,0 +1,10 @@
namespace AudibleApiDomainService
{
public class Settings
{
// identityTokens.json
public string IdentityFilePath { get; set; }
public string LocaleCountryCode { get; set; }
}
}

View File

@ -11,8 +11,8 @@ Microsoft.EntityFrameworkCore.Sqlite
MIGRATIONS require standard, not core MIGRATIONS require standard, not core
using standard instead of core. edit 3 things in csproj using standard instead of core. edit 3 things in csproj
1of3: pluralize xml TargetFramework tag to TargetFrameworks 1of3: pluralize xml TargetFramework tag to TargetFrameworks
2of2: TargetFrameworks from: netstandard2.0 2of2: TargetFrameworks from: netstandard2.1
to: netcoreapp2.1;netstandard2.0 to: netcoreapp3.0;netstandard2.1
3of3: add 3of3: add
<PropertyGroup> <PropertyGroup>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

View File

@ -80,6 +80,12 @@ namespace FileManager
set => persistentDictionary[nameof(DecryptInProgressEnum)] = value; set => persistentDictionary[nameof(DecryptInProgressEnum)] = value;
} }
public string LocaleCountryCode
{
get => persistentDictionary[nameof(LocaleCountryCode)];
set => persistentDictionary[nameof(LocaleCountryCode)] = value;
}
// singleton stuff // singleton stuff
public static Configuration Instance { get; } = new Configuration(); public static Configuration Instance { get; } = new Configuration();
private Configuration() private Configuration()
@ -135,11 +141,11 @@ namespace FileManager
private static string getNonDevelopmentDir(string path) private static string getNonDevelopmentDir(string path)
{ {
// examples: // examples:
// \Libation\Core2_0\bin\Debug\netcoreapp2.1 // \Libation\Core2_0\bin\Debug\netcoreapp3.0
// \Libation\StndLib\bin\Debug\netstandard2.0 // \Libation\StndLib\bin\Debug\netstandard2.1
// \Libation\MyWnfrm\bin\Debug // \Libation\MyWnfrm\bin\Debug
// \Libation\Core2_0\bin\Release\netcoreapp2.1 // \Libation\Core2_0\bin\Release\netcoreapp3.0
// \Libation\StndLib\bin\Release\netstandard2.0 // \Libation\StndLib\bin\Release\netstandard2.1
// \Libation\MyWnfrm\bin\Release // \Libation\MyWnfrm\bin\Release
var curr = new DirectoryInfo(path); var curr = new DirectoryInfo(path);

View File

@ -35,11 +35,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AudibleDotComAutomation", "
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookieMonster", "CookieMonster\CookieMonster.csproj", "{7BD02E29-3430-4D06-88D2-5CECEE9ABD01}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookieMonster", "CookieMonster\CookieMonster.csproj", "{7BD02E29-3430-4D06-88D2-5CECEE9ABD01}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DomainServices", "DomainServices\DomainServices.csproj", "{393B5B27-D15C-4F77-9457-FA14BA8F3C73}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScrapingDomainServices", "ScrapingDomainServices\ScrapingDomainServices.csproj", "{393B5B27-D15C-4F77-9457-FA14BA8F3C73}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternalUtilities", "InternalUtilities\InternalUtilities.csproj", "{06882742-27A6-4347-97D9-56162CEC9C11}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternalUtilities", "InternalUtilities\InternalUtilities.csproj", "{06882742-27A6-4347-97D9-56162CEC9C11}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.1 Domain Internal Utilities", "3.1 Domain Internal Utilities", "{F0CBB7A7-D3FB-41FF-8F47-CF3F6A592249}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.1 Domain Internal Utilities (db ignorant)", "3.1 Domain Internal Utilities (db ignorant)", "{F0CBB7A7-D3FB-41FF-8F47-CF3F6A592249}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibationSearchEngine", "LibationSearchEngine\LibationSearchEngine.csproj", "{2E1F5DB4-40CC-4804-A893-5DCE0193E598}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibationSearchEngine", "LibationSearchEngine\LibationSearchEngine.csproj", "{2E1F5DB4-40CC-4804-A893-5DCE0193E598}"
EndProject EndProject
@ -83,6 +83,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LuceneNet303r2.Tests", "..\
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTOs", "DTOs\DTOs.csproj", "{5FDA62B1-55FD-407A-BECA-38A969235541}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTOs", "DTOs\DTOs.csproj", "{5FDA62B1-55FD-407A-BECA-38A969235541}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudibleApiDomainService", "AudibleApiDomainService\AudibleApiDomainService.csproj", "{A1AB4B4B-6855-4BD0-BC54-C2FFDB20E050}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -201,6 +203,10 @@ Global
{5FDA62B1-55FD-407A-BECA-38A969235541}.Debug|Any CPU.Build.0 = Debug|Any CPU {5FDA62B1-55FD-407A-BECA-38A969235541}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FDA62B1-55FD-407A-BECA-38A969235541}.Release|Any CPU.ActiveCfg = Release|Any CPU {5FDA62B1-55FD-407A-BECA-38A969235541}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FDA62B1-55FD-407A-BECA-38A969235541}.Release|Any CPU.Build.0 = Release|Any CPU {5FDA62B1-55FD-407A-BECA-38A969235541}.Release|Any CPU.Build.0 = Release|Any CPU
{A1AB4B4B-6855-4BD0-BC54-C2FFDB20E050}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1AB4B4B-6855-4BD0-BC54-C2FFDB20E050}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1AB4B4B-6855-4BD0-BC54-C2FFDB20E050}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1AB4B4B-6855-4BD0-BC54-C2FFDB20E050}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -234,6 +240,7 @@ Global
{35803735-B669-4090-9681-CC7F7FABDC71} = {7FBBB086-0807-4998-85BF-6D1A49C8AD05} {35803735-B669-4090-9681-CC7F7FABDC71} = {7FBBB086-0807-4998-85BF-6D1A49C8AD05}
{5A7681A5-60D9-480B-9AC7-63E0812A2548} = {38E6C6D9-963A-4C5B-89F4-F2F14885ADFD} {5A7681A5-60D9-480B-9AC7-63E0812A2548} = {38E6C6D9-963A-4C5B-89F4-F2F14885ADFD}
{5FDA62B1-55FD-407A-BECA-38A969235541} = {7FBBB086-0807-4998-85BF-6D1A49C8AD05} {5FDA62B1-55FD-407A-BECA-38A969235541} = {7FBBB086-0807-4998-85BF-6D1A49C8AD05}
{A1AB4B4B-6855-4BD0-BC54-C2FFDB20E050} = {41CDCC73-9B81-49DD-9570-C54406E852AF}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {615E00ED-BAEF-4E8E-A92A-9B82D87942A9} SolutionGuid = {615E00ED-BAEF-4E8E-A92A-9B82D87942A9}

View File

@ -11,7 +11,8 @@
<ProjectReference Include="..\..\audible api\AudibleApi\AudibleApi\AudibleApi.csproj" /> <ProjectReference Include="..\..\audible api\AudibleApi\AudibleApi\AudibleApi.csproj" />
<ProjectReference Include="..\..\Dinah.Core\Dinah.Core.Drawing\Dinah.Core.Drawing.csproj" /> <ProjectReference Include="..\..\Dinah.Core\Dinah.Core.Drawing\Dinah.Core.Drawing.csproj" />
<ProjectReference Include="..\..\Dinah.Core\Dinah.Core.Windows.Forms\Dinah.Core.Windows.Forms.csproj" /> <ProjectReference Include="..\..\Dinah.Core\Dinah.Core.Windows.Forms\Dinah.Core.Windows.Forms.csproj" />
<ProjectReference Include="..\DomainServices\DomainServices.csproj" /> <ProjectReference Include="..\AudibleApiDomainService\AudibleApiDomainService.csproj" />
<ProjectReference Include="..\DomainServices\ScrapingDomainServices.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -55,6 +55,8 @@
this.decryptInProgressDescLbl = new System.Windows.Forms.Label(); this.decryptInProgressDescLbl = new System.Windows.Forms.Label();
this.saveBtn = new System.Windows.Forms.Button(); this.saveBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.audibleLocaleLbl = new System.Windows.Forms.Label();
this.audibleLocaleCb = new System.Windows.Forms.ComboBox();
this.libationFilesGb.SuspendLayout(); this.libationFilesGb.SuspendLayout();
this.downloadsInProgressGb.SuspendLayout(); this.downloadsInProgressGb.SuspendLayout();
this.decryptInProgressGb.SuspendLayout(); this.decryptInProgressGb.SuspendLayout();
@ -99,7 +101,7 @@
this.booksLocationLbl.Location = new System.Drawing.Point(7, 103); this.booksLocationLbl.Location = new System.Drawing.Point(7, 103);
this.booksLocationLbl.Name = "booksLocationLbl"; this.booksLocationLbl.Name = "booksLocationLbl";
this.booksLocationLbl.Size = new System.Drawing.Size(77, 13); this.booksLocationLbl.Size = new System.Drawing.Size(77, 13);
this.booksLocationLbl.TabIndex = 6; this.booksLocationLbl.TabIndex = 8;
this.booksLocationLbl.Text = "Books location"; this.booksLocationLbl.Text = "Books location";
// //
// booksLocationTb // booksLocationTb
@ -107,14 +109,14 @@
this.booksLocationTb.Location = new System.Drawing.Point(90, 100); this.booksLocationTb.Location = new System.Drawing.Point(90, 100);
this.booksLocationTb.Name = "booksLocationTb"; this.booksLocationTb.Name = "booksLocationTb";
this.booksLocationTb.Size = new System.Drawing.Size(657, 20); this.booksLocationTb.Size = new System.Drawing.Size(657, 20);
this.booksLocationTb.TabIndex = 7; this.booksLocationTb.TabIndex = 9;
// //
// booksLocationSearchBtn // booksLocationSearchBtn
// //
this.booksLocationSearchBtn.Location = new System.Drawing.Point(753, 98); this.booksLocationSearchBtn.Location = new System.Drawing.Point(753, 98);
this.booksLocationSearchBtn.Name = "booksLocationSearchBtn"; this.booksLocationSearchBtn.Name = "booksLocationSearchBtn";
this.booksLocationSearchBtn.Size = new System.Drawing.Size(35, 23); this.booksLocationSearchBtn.Size = new System.Drawing.Size(35, 23);
this.booksLocationSearchBtn.TabIndex = 8; this.booksLocationSearchBtn.TabIndex = 10;
this.booksLocationSearchBtn.Text = "..."; this.booksLocationSearchBtn.Text = "...";
this.booksLocationSearchBtn.UseVisualStyleBackColor = true; this.booksLocationSearchBtn.UseVisualStyleBackColor = true;
this.booksLocationSearchBtn.Click += new System.EventHandler(this.booksLocationSearchBtn_Click); this.booksLocationSearchBtn.Click += new System.EventHandler(this.booksLocationSearchBtn_Click);
@ -143,7 +145,7 @@
this.booksLocationDescLbl.Location = new System.Drawing.Point(87, 123); this.booksLocationDescLbl.Location = new System.Drawing.Point(87, 123);
this.booksLocationDescLbl.Name = "booksLocationDescLbl"; this.booksLocationDescLbl.Name = "booksLocationDescLbl";
this.booksLocationDescLbl.Size = new System.Drawing.Size(36, 13); this.booksLocationDescLbl.Size = new System.Drawing.Size(36, 13);
this.booksLocationDescLbl.TabIndex = 9; this.booksLocationDescLbl.TabIndex = 11;
this.booksLocationDescLbl.Text = "[desc]"; this.booksLocationDescLbl.Text = "[desc]";
// //
// libationFilesGb // libationFilesGb
@ -157,7 +159,7 @@
this.libationFilesGb.Location = new System.Drawing.Point(12, 139); this.libationFilesGb.Location = new System.Drawing.Point(12, 139);
this.libationFilesGb.Name = "libationFilesGb"; this.libationFilesGb.Name = "libationFilesGb";
this.libationFilesGb.Size = new System.Drawing.Size(776, 131); this.libationFilesGb.Size = new System.Drawing.Size(776, 131);
this.libationFilesGb.TabIndex = 10; this.libationFilesGb.TabIndex = 12;
this.libationFilesGb.TabStop = false; this.libationFilesGb.TabStop = false;
this.libationFilesGb.Text = "Libation files"; this.libationFilesGb.Text = "Libation files";
// //
@ -235,7 +237,7 @@
this.downloadsInProgressGb.Location = new System.Drawing.Point(12, 276); this.downloadsInProgressGb.Location = new System.Drawing.Point(12, 276);
this.downloadsInProgressGb.Name = "downloadsInProgressGb"; this.downloadsInProgressGb.Name = "downloadsInProgressGb";
this.downloadsInProgressGb.Size = new System.Drawing.Size(776, 117); this.downloadsInProgressGb.Size = new System.Drawing.Size(776, 117);
this.downloadsInProgressGb.TabIndex = 11; this.downloadsInProgressGb.TabIndex = 13;
this.downloadsInProgressGb.TabStop = false; this.downloadsInProgressGb.TabStop = false;
this.downloadsInProgressGb.Text = "Downloads in progress"; this.downloadsInProgressGb.Text = "Downloads in progress";
// //
@ -280,7 +282,7 @@
this.decryptInProgressGb.Location = new System.Drawing.Point(12, 399); this.decryptInProgressGb.Location = new System.Drawing.Point(12, 399);
this.decryptInProgressGb.Name = "decryptInProgressGb"; this.decryptInProgressGb.Name = "decryptInProgressGb";
this.decryptInProgressGb.Size = new System.Drawing.Size(776, 117); this.decryptInProgressGb.Size = new System.Drawing.Size(776, 117);
this.decryptInProgressGb.TabIndex = 12; this.decryptInProgressGb.TabIndex = 14;
this.decryptInProgressGb.TabStop = false; this.decryptInProgressGb.TabStop = false;
this.decryptInProgressGb.Text = "Decrypt in progress"; this.decryptInProgressGb.Text = "Decrypt in progress";
// //
@ -291,7 +293,7 @@
this.decryptInProgressLibationFilesRb.Location = new System.Drawing.Point(6, 81); this.decryptInProgressLibationFilesRb.Location = new System.Drawing.Point(6, 81);
this.decryptInProgressLibationFilesRb.Name = "decryptInProgressLibationFilesRb"; this.decryptInProgressLibationFilesRb.Name = "decryptInProgressLibationFilesRb";
this.decryptInProgressLibationFilesRb.Size = new System.Drawing.Size(177, 30); this.decryptInProgressLibationFilesRb.Size = new System.Drawing.Size(177, 30);
this.decryptInProgressLibationFilesRb.TabIndex = 3; this.decryptInProgressLibationFilesRb.TabIndex = 2;
this.decryptInProgressLibationFilesRb.TabStop = true; this.decryptInProgressLibationFilesRb.TabStop = true;
this.decryptInProgressLibationFilesRb.Text = "[desc]\r\n[libationFiles\\DecryptInProgress]"; this.decryptInProgressLibationFilesRb.Text = "[desc]\r\n[libationFiles\\DecryptInProgress]";
this.decryptInProgressLibationFilesRb.UseVisualStyleBackColor = true; this.decryptInProgressLibationFilesRb.UseVisualStyleBackColor = true;
@ -303,7 +305,7 @@
this.decryptInProgressWinTempRb.Location = new System.Drawing.Point(6, 45); this.decryptInProgressWinTempRb.Location = new System.Drawing.Point(6, 45);
this.decryptInProgressWinTempRb.Name = "decryptInProgressWinTempRb"; this.decryptInProgressWinTempRb.Name = "decryptInProgressWinTempRb";
this.decryptInProgressWinTempRb.Size = new System.Drawing.Size(166, 30); this.decryptInProgressWinTempRb.Size = new System.Drawing.Size(166, 30);
this.decryptInProgressWinTempRb.TabIndex = 2; this.decryptInProgressWinTempRb.TabIndex = 1;
this.decryptInProgressWinTempRb.TabStop = true; this.decryptInProgressWinTempRb.TabStop = true;
this.decryptInProgressWinTempRb.Text = "[desc]\r\n[winTemp\\DecryptInProgress]"; this.decryptInProgressWinTempRb.Text = "[desc]\r\n[winTemp\\DecryptInProgress]";
this.decryptInProgressWinTempRb.UseVisualStyleBackColor = true; this.decryptInProgressWinTempRb.UseVisualStyleBackColor = true;
@ -314,7 +316,7 @@
this.decryptInProgressDescLbl.Location = new System.Drawing.Point(6, 16); this.decryptInProgressDescLbl.Location = new System.Drawing.Point(6, 16);
this.decryptInProgressDescLbl.Name = "decryptInProgressDescLbl"; this.decryptInProgressDescLbl.Name = "decryptInProgressDescLbl";
this.decryptInProgressDescLbl.Size = new System.Drawing.Size(38, 26); this.decryptInProgressDescLbl.Size = new System.Drawing.Size(38, 26);
this.decryptInProgressDescLbl.TabIndex = 1; this.decryptInProgressDescLbl.TabIndex = 0;
this.decryptInProgressDescLbl.Text = "[desc]\r\n[line 2]"; this.decryptInProgressDescLbl.Text = "[desc]\r\n[line 2]";
// //
// saveBtn // saveBtn
@ -323,7 +325,7 @@
this.saveBtn.Location = new System.Drawing.Point(612, 522); this.saveBtn.Location = new System.Drawing.Point(612, 522);
this.saveBtn.Name = "saveBtn"; this.saveBtn.Name = "saveBtn";
this.saveBtn.Size = new System.Drawing.Size(75, 23); this.saveBtn.Size = new System.Drawing.Size(75, 23);
this.saveBtn.TabIndex = 13; this.saveBtn.TabIndex = 15;
this.saveBtn.Text = "Save"; this.saveBtn.Text = "Save";
this.saveBtn.UseVisualStyleBackColor = true; this.saveBtn.UseVisualStyleBackColor = true;
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click); this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
@ -335,10 +337,34 @@
this.cancelBtn.Location = new System.Drawing.Point(713, 522); this.cancelBtn.Location = new System.Drawing.Point(713, 522);
this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(75, 23); this.cancelBtn.Size = new System.Drawing.Size(75, 23);
this.cancelBtn.TabIndex = 14; this.cancelBtn.TabIndex = 16;
this.cancelBtn.Text = "Cancel"; this.cancelBtn.Text = "Cancel";
this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.UseVisualStyleBackColor = true;
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click); this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
//
// audibleLocaleLbl
//
this.audibleLocaleLbl.AutoSize = true;
this.audibleLocaleLbl.Location = new System.Drawing.Point(273, 59);
this.audibleLocaleLbl.Name = "audibleLocaleLbl";
this.audibleLocaleLbl.Size = new System.Drawing.Size(77, 13);
this.audibleLocaleLbl.TabIndex = 6;
this.audibleLocaleLbl.Text = "Audible Locale";
//
// audibleLocaleCb
//
this.audibleLocaleCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.audibleLocaleCb.FormattingEnabled = true;
this.audibleLocaleCb.Items.AddRange(new object[] {
"us",
"uk",
"germany",
"france",
"canada"});
this.audibleLocaleCb.Location = new System.Drawing.Point(356, 56);
this.audibleLocaleCb.Name = "audibleLocaleCb";
this.audibleLocaleCb.Size = new System.Drawing.Size(121, 21);
this.audibleLocaleCb.TabIndex = 7;
// //
// SettingsDialog // SettingsDialog
// //
@ -347,6 +373,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelBtn; this.CancelButton = this.cancelBtn;
this.ClientSize = new System.Drawing.Size(800, 557); this.ClientSize = new System.Drawing.Size(800, 557);
this.Controls.Add(this.audibleLocaleCb);
this.Controls.Add(this.audibleLocaleLbl);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.saveBtn); this.Controls.Add(this.saveBtn);
this.Controls.Add(this.decryptInProgressGb); this.Controls.Add(this.decryptInProgressGb);
@ -407,5 +435,7 @@
private System.Windows.Forms.RadioButton decryptInProgressWinTempRb; private System.Windows.Forms.RadioButton decryptInProgressWinTempRb;
private System.Windows.Forms.Button saveBtn; private System.Windows.Forms.Button saveBtn;
private System.Windows.Forms.Button cancelBtn; private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.Label audibleLocaleLbl;
private System.Windows.Forms.ComboBox audibleLocaleCb;
} }
} }

View File

@ -23,6 +23,7 @@ namespace LibationWinForm
public SettingsDialog() public SettingsDialog()
{ {
InitializeComponent(); InitializeComponent();
audibleLocaleCb.SelectedIndex = 0;
exeRoot = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), "Libation")); exeRoot = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), "Libation"));
myDocs = Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Libation")); myDocs = Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Libation"));
@ -39,6 +40,8 @@ namespace LibationWinForm
this.booksLocationTb.Text = config.Books; this.booksLocationTb.Text = config.Books;
this.booksLocationDescLbl.Text = desc(nameof(config.Books)); this.booksLocationDescLbl.Text = desc(nameof(config.Books));
this.audibleLocaleCb.Text = config.LocaleCountryCode;
libationFilesDescLbl.Text = desc(nameof(config.LibationFiles)); libationFilesDescLbl.Text = desc(nameof(config.LibationFiles));
this.libationFilesRootRb.Text = "In the same folder that Libation is running from\r\n" + exeRoot; this.libationFilesRootRb.Text = "In the same folder that Libation is running from\r\n" + exeRoot;
this.libationFilesMyDocsRb.Text = "In My Documents\r\n" + myDocs; this.libationFilesMyDocsRb.Text = "In My Documents\r\n" + myDocs;
@ -103,7 +106,7 @@ namespace LibationWinForm
private static void selectFolder(string desc, TextBox textbox) private static void selectFolder(string desc, TextBox textbox)
{ {
var dialog = new FolderBrowserDialog { Description = desc, SelectedPath = "" }; using var dialog = new FolderBrowserDialog { Description = desc, SelectedPath = "" };
dialog.ShowDialog(); dialog.ShowDialog();
if (!string.IsNullOrWhiteSpace(dialog.SelectedPath)) if (!string.IsNullOrWhiteSpace(dialog.SelectedPath))
textbox.Text = dialog.SelectedPath; textbox.Text = dialog.SelectedPath;
@ -123,6 +126,8 @@ namespace LibationWinForm
config.Books = this.booksLocationTb.Text; config.Books = this.booksLocationTb.Text;
} }
config.LocaleCountryCode = this.audibleLocaleCb.Text;
var libationDir var libationDir
= libationFilesRootRb.Checked ? exeRoot = libationFilesRootRb.Checked ? exeRoot
: libationFilesMyDocsRb.Checked ? myDocs : libationFilesMyDocsRb.Checked ? myDocs

View File

@ -358,6 +358,8 @@ namespace LibationWinForm
private async void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e) private async void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e)
{ {
// audible api // audible api
//var client = new AudibleApiDomainService.AudibleApiLibationClient(config.);
//await client.ImportLibraryAsync();
// scrape // scrape
await indexDialog(new ScanLibraryDialog()); await indexDialog(new ScanLibraryDialog());

View File

@ -12,10 +12,10 @@ utils: domain ignorant
domain: biz logic domain: biz logic
db ignorant db ignorant
db, domain objects db, domain objects
db aware domain internal utilities: domain aware. db ignorant
domain utilities: domain aware. db aware
incl non-db persistence. unless it needs to be tied into a db intercepter incl non-db persistence. unless it needs to be tied into a db intercepter
all user-provided data must be backed up to json all user-provided data must be backed up to json
utilities: domain aware
application application
do NOT combine jsons for do NOT combine jsons for

View File

@ -55,6 +55,8 @@
this.decryptInProgressDescLbl = new System.Windows.Forms.Label(); this.decryptInProgressDescLbl = new System.Windows.Forms.Label();
this.saveBtn = new System.Windows.Forms.Button(); this.saveBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.audibleLocaleLbl = new System.Windows.Forms.Label();
this.audibleLocaleCb = new System.Windows.Forms.ComboBox();
this.libationFilesGb.SuspendLayout(); this.libationFilesGb.SuspendLayout();
this.downloadsInProgressGb.SuspendLayout(); this.downloadsInProgressGb.SuspendLayout();
this.decryptInProgressGb.SuspendLayout(); this.decryptInProgressGb.SuspendLayout();
@ -99,7 +101,7 @@
this.booksLocationLbl.Location = new System.Drawing.Point(7, 103); this.booksLocationLbl.Location = new System.Drawing.Point(7, 103);
this.booksLocationLbl.Name = "booksLocationLbl"; this.booksLocationLbl.Name = "booksLocationLbl";
this.booksLocationLbl.Size = new System.Drawing.Size(77, 13); this.booksLocationLbl.Size = new System.Drawing.Size(77, 13);
this.booksLocationLbl.TabIndex = 6; this.booksLocationLbl.TabIndex = 8;
this.booksLocationLbl.Text = "Books location"; this.booksLocationLbl.Text = "Books location";
// //
// booksLocationTb // booksLocationTb
@ -107,14 +109,14 @@
this.booksLocationTb.Location = new System.Drawing.Point(90, 100); this.booksLocationTb.Location = new System.Drawing.Point(90, 100);
this.booksLocationTb.Name = "booksLocationTb"; this.booksLocationTb.Name = "booksLocationTb";
this.booksLocationTb.Size = new System.Drawing.Size(657, 20); this.booksLocationTb.Size = new System.Drawing.Size(657, 20);
this.booksLocationTb.TabIndex = 7; this.booksLocationTb.TabIndex = 9;
// //
// booksLocationSearchBtn // booksLocationSearchBtn
// //
this.booksLocationSearchBtn.Location = new System.Drawing.Point(753, 98); this.booksLocationSearchBtn.Location = new System.Drawing.Point(753, 98);
this.booksLocationSearchBtn.Name = "booksLocationSearchBtn"; this.booksLocationSearchBtn.Name = "booksLocationSearchBtn";
this.booksLocationSearchBtn.Size = new System.Drawing.Size(35, 23); this.booksLocationSearchBtn.Size = new System.Drawing.Size(35, 23);
this.booksLocationSearchBtn.TabIndex = 8; this.booksLocationSearchBtn.TabIndex = 10;
this.booksLocationSearchBtn.Text = "..."; this.booksLocationSearchBtn.Text = "...";
this.booksLocationSearchBtn.UseVisualStyleBackColor = true; this.booksLocationSearchBtn.UseVisualStyleBackColor = true;
// //
@ -142,7 +144,7 @@
this.booksLocationDescLbl.Location = new System.Drawing.Point(87, 123); this.booksLocationDescLbl.Location = new System.Drawing.Point(87, 123);
this.booksLocationDescLbl.Name = "booksLocationDescLbl"; this.booksLocationDescLbl.Name = "booksLocationDescLbl";
this.booksLocationDescLbl.Size = new System.Drawing.Size(36, 13); this.booksLocationDescLbl.Size = new System.Drawing.Size(36, 13);
this.booksLocationDescLbl.TabIndex = 9; this.booksLocationDescLbl.TabIndex = 11;
this.booksLocationDescLbl.Text = "[desc]"; this.booksLocationDescLbl.Text = "[desc]";
// //
// libationFilesGb // libationFilesGb
@ -156,7 +158,7 @@
this.libationFilesGb.Location = new System.Drawing.Point(12, 139); this.libationFilesGb.Location = new System.Drawing.Point(12, 139);
this.libationFilesGb.Name = "libationFilesGb"; this.libationFilesGb.Name = "libationFilesGb";
this.libationFilesGb.Size = new System.Drawing.Size(776, 131); this.libationFilesGb.Size = new System.Drawing.Size(776, 131);
this.libationFilesGb.TabIndex = 10; this.libationFilesGb.TabIndex = 12;
this.libationFilesGb.TabStop = false; this.libationFilesGb.TabStop = false;
this.libationFilesGb.Text = "Libation files"; this.libationFilesGb.Text = "Libation files";
// //
@ -230,7 +232,7 @@
this.downloadsInProgressGb.Location = new System.Drawing.Point(12, 276); this.downloadsInProgressGb.Location = new System.Drawing.Point(12, 276);
this.downloadsInProgressGb.Name = "downloadsInProgressGb"; this.downloadsInProgressGb.Name = "downloadsInProgressGb";
this.downloadsInProgressGb.Size = new System.Drawing.Size(776, 117); this.downloadsInProgressGb.Size = new System.Drawing.Size(776, 117);
this.downloadsInProgressGb.TabIndex = 11; this.downloadsInProgressGb.TabIndex = 13;
this.downloadsInProgressGb.TabStop = false; this.downloadsInProgressGb.TabStop = false;
this.downloadsInProgressGb.Text = "Downloads in progress"; this.downloadsInProgressGb.Text = "Downloads in progress";
// //
@ -275,7 +277,7 @@
this.decryptInProgressGb.Location = new System.Drawing.Point(12, 399); this.decryptInProgressGb.Location = new System.Drawing.Point(12, 399);
this.decryptInProgressGb.Name = "decryptInProgressGb"; this.decryptInProgressGb.Name = "decryptInProgressGb";
this.decryptInProgressGb.Size = new System.Drawing.Size(776, 117); this.decryptInProgressGb.Size = new System.Drawing.Size(776, 117);
this.decryptInProgressGb.TabIndex = 12; this.decryptInProgressGb.TabIndex = 14;
this.decryptInProgressGb.TabStop = false; this.decryptInProgressGb.TabStop = false;
this.decryptInProgressGb.Text = "Decrypt in progress"; this.decryptInProgressGb.Text = "Decrypt in progress";
// //
@ -286,7 +288,7 @@
this.decryptInProgressLibationFilesRb.Location = new System.Drawing.Point(6, 81); this.decryptInProgressLibationFilesRb.Location = new System.Drawing.Point(6, 81);
this.decryptInProgressLibationFilesRb.Name = "decryptInProgressLibationFilesRb"; this.decryptInProgressLibationFilesRb.Name = "decryptInProgressLibationFilesRb";
this.decryptInProgressLibationFilesRb.Size = new System.Drawing.Size(177, 30); this.decryptInProgressLibationFilesRb.Size = new System.Drawing.Size(177, 30);
this.decryptInProgressLibationFilesRb.TabIndex = 3; this.decryptInProgressLibationFilesRb.TabIndex = 2;
this.decryptInProgressLibationFilesRb.TabStop = true; this.decryptInProgressLibationFilesRb.TabStop = true;
this.decryptInProgressLibationFilesRb.Text = "[desc]\r\n[libationFiles\\DecryptInProgress]"; this.decryptInProgressLibationFilesRb.Text = "[desc]\r\n[libationFiles\\DecryptInProgress]";
this.decryptInProgressLibationFilesRb.UseVisualStyleBackColor = true; this.decryptInProgressLibationFilesRb.UseVisualStyleBackColor = true;
@ -298,7 +300,7 @@
this.decryptInProgressWinTempRb.Location = new System.Drawing.Point(6, 45); this.decryptInProgressWinTempRb.Location = new System.Drawing.Point(6, 45);
this.decryptInProgressWinTempRb.Name = "decryptInProgressWinTempRb"; this.decryptInProgressWinTempRb.Name = "decryptInProgressWinTempRb";
this.decryptInProgressWinTempRb.Size = new System.Drawing.Size(166, 30); this.decryptInProgressWinTempRb.Size = new System.Drawing.Size(166, 30);
this.decryptInProgressWinTempRb.TabIndex = 2; this.decryptInProgressWinTempRb.TabIndex = 1;
this.decryptInProgressWinTempRb.TabStop = true; this.decryptInProgressWinTempRb.TabStop = true;
this.decryptInProgressWinTempRb.Text = "[desc]\r\n[winTemp\\DecryptInProgress]"; this.decryptInProgressWinTempRb.Text = "[desc]\r\n[winTemp\\DecryptInProgress]";
this.decryptInProgressWinTempRb.UseVisualStyleBackColor = true; this.decryptInProgressWinTempRb.UseVisualStyleBackColor = true;
@ -309,7 +311,7 @@
this.decryptInProgressDescLbl.Location = new System.Drawing.Point(6, 16); this.decryptInProgressDescLbl.Location = new System.Drawing.Point(6, 16);
this.decryptInProgressDescLbl.Name = "decryptInProgressDescLbl"; this.decryptInProgressDescLbl.Name = "decryptInProgressDescLbl";
this.decryptInProgressDescLbl.Size = new System.Drawing.Size(38, 26); this.decryptInProgressDescLbl.Size = new System.Drawing.Size(38, 26);
this.decryptInProgressDescLbl.TabIndex = 1; this.decryptInProgressDescLbl.TabIndex = 0;
this.decryptInProgressDescLbl.Text = "[desc]\r\n[line 2]"; this.decryptInProgressDescLbl.Text = "[desc]\r\n[line 2]";
// //
// saveBtn // saveBtn
@ -318,7 +320,7 @@
this.saveBtn.Location = new System.Drawing.Point(612, 522); this.saveBtn.Location = new System.Drawing.Point(612, 522);
this.saveBtn.Name = "saveBtn"; this.saveBtn.Name = "saveBtn";
this.saveBtn.Size = new System.Drawing.Size(75, 23); this.saveBtn.Size = new System.Drawing.Size(75, 23);
this.saveBtn.TabIndex = 13; this.saveBtn.TabIndex = 15;
this.saveBtn.Text = "Save"; this.saveBtn.Text = "Save";
this.saveBtn.UseVisualStyleBackColor = true; this.saveBtn.UseVisualStyleBackColor = true;
// //
@ -329,10 +331,34 @@
this.cancelBtn.Location = new System.Drawing.Point(713, 522); this.cancelBtn.Location = new System.Drawing.Point(713, 522);
this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(75, 23); this.cancelBtn.Size = new System.Drawing.Size(75, 23);
this.cancelBtn.TabIndex = 14; this.cancelBtn.TabIndex = 16;
this.cancelBtn.Text = "Cancel"; this.cancelBtn.Text = "Cancel";
this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.UseVisualStyleBackColor = true;
// //
// audibleLocaleLbl
//
this.audibleLocaleLbl.AutoSize = true;
this.audibleLocaleLbl.Location = new System.Drawing.Point(273, 59);
this.audibleLocaleLbl.Name = "audibleLocaleLbl";
this.audibleLocaleLbl.Size = new System.Drawing.Size(77, 13);
this.audibleLocaleLbl.TabIndex = 6;
this.audibleLocaleLbl.Text = "Audible Locale";
//
// audibleLocaleCb
//
this.audibleLocaleCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.audibleLocaleCb.FormattingEnabled = true;
this.audibleLocaleCb.Items.AddRange(new object[] {
"us",
"uk",
"germany",
"france",
"canada"});
this.audibleLocaleCb.Location = new System.Drawing.Point(356, 56);
this.audibleLocaleCb.Name = "audibleLocaleCb";
this.audibleLocaleCb.Size = new System.Drawing.Size(121, 21);
this.audibleLocaleCb.TabIndex = 7;
//
// SettingsDialog // SettingsDialog
// //
this.AcceptButton = this.saveBtn; this.AcceptButton = this.saveBtn;
@ -340,6 +366,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelBtn; this.CancelButton = this.cancelBtn;
this.ClientSize = new System.Drawing.Size(800, 557); this.ClientSize = new System.Drawing.Size(800, 557);
this.Controls.Add(this.audibleLocaleCb);
this.Controls.Add(this.audibleLocaleLbl);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.saveBtn); this.Controls.Add(this.saveBtn);
this.Controls.Add(this.decryptInProgressGb); this.Controls.Add(this.decryptInProgressGb);
@ -399,5 +427,7 @@
private System.Windows.Forms.RadioButton decryptInProgressWinTempRb; private System.Windows.Forms.RadioButton decryptInProgressWinTempRb;
private System.Windows.Forms.Button saveBtn; private System.Windows.Forms.Button saveBtn;
private System.Windows.Forms.Button cancelBtn; private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.Label audibleLocaleLbl;
private System.Windows.Forms.ComboBox audibleLocaleCb;
} }
} }

View File

@ -8,6 +8,7 @@ namespace WinFormsDesigner
public SettingsDialog() public SettingsDialog()
{ {
InitializeComponent(); InitializeComponent();
audibleLocaleCb.SelectedIndex = 0;
} }
} }
} }