Removed "legacy inAudible wire-up code"
This commit is contained in:
parent
4f7b66d64e
commit
bd993b4e4d
@ -164,148 +164,5 @@ namespace FileLiberator
|
||||
File.Move(f.FullName, dest);
|
||||
}
|
||||
}
|
||||
|
||||
#region legacy inAudible wire-up code
|
||||
//
|
||||
// instructions are in comments below for editing and interacting with inAudible. eg:
|
||||
// \_NET\Visual Studio 2017\inAudible197\decompiled - in progress\inAudible.csproj
|
||||
// first, add its project and put its exe path into inAudiblePath
|
||||
//
|
||||
#region placeholder code
|
||||
// this exists so the below legacy code will compile as-is. comment out placeholder code when actually connecting to inAudible
|
||||
|
||||
class Form
|
||||
{
|
||||
internal void Show() => throw new NotImplementedException();
|
||||
internal void Kill() => throw new NotImplementedException();
|
||||
}
|
||||
class TextBox
|
||||
{
|
||||
internal string Text { set => throw new NotImplementedException(); }
|
||||
}
|
||||
class Button
|
||||
{
|
||||
internal void PerformClick() => throw new NotImplementedException();
|
||||
}
|
||||
class AudibleConvertor
|
||||
{
|
||||
internal class GLOBALS
|
||||
{
|
||||
internal static string ExecutablePath { set => throw new NotImplementedException(); }
|
||||
}
|
||||
internal class Form1 : Form
|
||||
{
|
||||
internal Form1(Action<string> action) => throw new NotImplementedException();
|
||||
internal void LoadAudibleFiles(string[] arr) => throw new NotImplementedException();
|
||||
internal TextBox txtOutputFile { get => throw new NotImplementedException(); }
|
||||
internal Button btnConvert { get => throw new NotImplementedException(); }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static string inAudiblePath { get; }
|
||||
= @"C:\"
|
||||
+ @"DEV_ROOT_EXAMPLE\"
|
||||
+ @"_NET\Visual Studio 2017\"
|
||||
+ @"inAudible197\decompiled - in progress\bin\Debug\inAudible.exe";
|
||||
private static async Task<string> inAudibleDecrypt(string proposedOutputFile, string aaxFilename)
|
||||
{
|
||||
#region // inAudible code to change:
|
||||
/*
|
||||
* Prevent "Path too long" error
|
||||
* =============================
|
||||
* BatchFiles.cs :: GenerateOutputFilepath()
|
||||
* Add this just before the bottom return statement
|
||||
*
|
||||
if (oneOff && !string.IsNullOrWhiteSpace(outputPath))
|
||||
return str + "\\" + Path.GetFileNameWithoutExtension(outputPath) + "." + fileType;
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region init inAudible
|
||||
#region // suppress warnings
|
||||
// inAudible. project properties > Build > Warning level=2
|
||||
#endregion
|
||||
#region // instructions to create inAudible ExecutablePath
|
||||
/*
|
||||
* STEP 1
|
||||
* ======
|
||||
* do a PROJECT level find/replace within inAudible
|
||||
* find
|
||||
* Application.ExecutablePath
|
||||
* replace
|
||||
* AudibleConvertor.GLOBALS.ExecutablePath
|
||||
* STEP 2
|
||||
* ======
|
||||
* new inAudible root-level file
|
||||
* _GLOBALS.cs
|
||||
* contents:
|
||||
* namespace AudibleConvertor { public static class GLOBALS { public static string ExecutablePath { get; set; } = System.Windows.Forms.Application.ExecutablePath; } }
|
||||
*/
|
||||
#endregion
|
||||
AudibleConvertor.GLOBALS.ExecutablePath = inAudiblePath;
|
||||
// before using inAudible, set ini values
|
||||
setIniValues(new Dictionary<string, string> { ["selected_codec"] = "lossless", ["embed_cover"] = "True", ["copy_cover_art"] = "False", ["create_cue"] = "True", ["nfo"] = "True", ["strip_unabridged"] = "True", });
|
||||
#endregion
|
||||
|
||||
// this provides the async magic to keep all of the form calling code in one method instead of event callback pattern
|
||||
// TODO: error handling is not obvious:
|
||||
// https://deaddesk.top/don't-fall-for-TaskCompletionSource-traps/
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
|
||||
// to know when inAudible is complete. code to change:
|
||||
#region // code to preceed ctor
|
||||
/*
|
||||
Action<string> _conversionCompleteAction;
|
||||
public Form1(Action<string> conversionCompleteAction) : this() => _conversionCompleteAction = conversionCompleteAction;
|
||||
*/
|
||||
#endregion
|
||||
#region // code for the end of bgwAAX_Completed()
|
||||
/*
|
||||
if (this.myAdvancedOptions.beep && !this.myAdvancedOptions.cylon) this.SOXPlay(Form1.appPath + "\\beep.mp3", true);
|
||||
else if (myAdvancedOptions.cylon) SOXPlay(appPath + "\\inAudible-end.mp3", true);
|
||||
_conversionCompleteAction?.Invoke(outputFileName);
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region start inAudible
|
||||
var form = new AudibleConvertor.Form1(tcs.SetResult);
|
||||
form.Show();
|
||||
form.LoadAudibleFiles(new string[] { aaxFilename }); // inAudible: make public
|
||||
|
||||
// change output info to include asin. put in temp
|
||||
form.txtOutputFile.Text = proposedOutputFile; // inAudible: make public
|
||||
|
||||
// submit/process/decrypt
|
||||
form.btnConvert.PerformClick(); // inAudible: make public
|
||||
|
||||
// ta-da -- magic! we stop here until inAudible complete
|
||||
var outputAudioFilename = await tcs.Task;
|
||||
#endregion
|
||||
|
||||
#region when complete, close inAudible
|
||||
// use this instead of Dinah.Core.Windows.Forms.UIThread()
|
||||
form.Kill();
|
||||
#endregion
|
||||
|
||||
return outputAudioFilename;
|
||||
}
|
||||
|
||||
private static void setIniValues(Dictionary<string, string> settings)
|
||||
{
|
||||
// C:\Users\username\Documents\inAudible\config.ini
|
||||
var iniPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "inAudible", "config.ini");
|
||||
var iniContents = File.ReadAllText(iniPath);
|
||||
|
||||
foreach (var kvp in settings)
|
||||
iniContents = System.Text.RegularExpressions.Regex.Replace(
|
||||
iniContents,
|
||||
$@"\r\n{kvp.Key} = [^\r\n]+\r\n",
|
||||
$"\r\n{kvp.Key} = {kvp.Value}\r\n");
|
||||
|
||||
File.WriteAllText(iniPath, iniContents);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
-- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
|
||||
https://github.com/rmcrackan/Libation/releases
|
||||
|
||||
v3.0.1 : Legacy inAudible wire-up code is still present but is commented out. All future check-ins are not guaranteed to have inAudible wire-up code
|
||||
v3.0 : This version is fully powered by the Audible API. Legacy scraping code is still present but is commented out. All future check-ins are not guaranteed to have any scraping code
|
||||
-- end VERSIONING ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
-- begin REPLACE SCRAPING WITH API ---------------------------------------------------------------------------------------------------------------------
|
||||
remove "legacy inAudible wire-up code"
|
||||
-- end REPLACE SCRAPING WITH API ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- begin ENHANCEMENT, PERFORMANCE: IMPORT ---------------------------------------------------------------------------------------------------------------------
|
||||
-- begin ENHANCEMENT, PERFORMANCE: IMPORT ---------------------------------------------------------------------------------------------------------------------
|
||||
imports are PAINFULLY slow for just a few hundred items. wtf is taking so long?
|
||||
-- end ENHANCEMENT, PERFORMANCE: IMPORT ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user