diff --git a/PhotosImporter.csproj b/PhotosImporter.csproj
index 02b225b..722aae5 100644
--- a/PhotosImporter.csproj
+++ b/PhotosImporter.csproj
@@ -19,6 +19,7 @@
+
diff --git a/Program.cs b/Program.cs
index d153dfd..f7d9ec1 100644
--- a/Program.cs
+++ b/Program.cs
@@ -7,6 +7,8 @@ using System.Text;
using System.Management.Automation;
using System.IO;
using Microsoft.PowerShell.Commands;
+using Mysqlx.Crud;
+using Spectre.Console;
namespace PhotosImporter
{
public class Program
@@ -23,7 +25,7 @@ namespace PhotosImporter
return ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
}
}
- public class ImportCommand : ConsoleCommand
+ public class ImportCommand : ConsoleCommand // deez nuts
{
private const int Success = 0;
private const int Failure = 2;
@@ -156,15 +158,15 @@ namespace PhotosImporter
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
- Console.WriteLine(output);
+ //Console.WriteLine(output); //dep 5/3/25
dynamic tmp = JsonConvert.DeserializeObject(output);
p.WaitForExit();
if (tmp[0].ContainsKey("TagsList")) {
- return JsonConvert.SerializeObject(tmp[0]["TagsList"]);
+ return string.Join(":", tmp[0]["TagsList"]);
} else
{
- return "{}";
+ return null;
}
//Console.WriteLine("Line 100: Tags (none)");
@@ -253,31 +255,51 @@ namespace PhotosImporter
string[] videoExtensions = GetVideoExtensions(videoExtensionsPath);
List badFileNotifications = new List();
- Console.WriteLine("Deleting and re-indexing in 10 seconds...");
+ // Console.WriteLine("Deleting and re-indexing in 10 seconds...");
// System.Threading.Thread.Sleep(10000);
if (LiveUpdate) {
DeleteRecords(PhotosTable);
ReIndexRecords(PhotosTable);
}
- foreach (string filename in Directory.GetFiles(PhotosPath))
+ //new ProgressBarColumn { IndeterminateStyle}.
+ AnsiConsole.Progress()
+ .AutoRefresh(true) // Turn off auto refresh
+ .AutoClear(false) // Do not remove the task list when done
+ .HideCompleted(false) // Hide tasks as they are completed
+ .Columns(new ProgressColumn[]
+ {
+ new SpinnerColumn(Spinner.Known.BoxBounce), // Task description
+ new ProgressBarColumn(), // Progress bar
+ new PercentageColumn(), // Percentage
+ new RemainingTimeColumn(), // Remaining time
+ }).Start(ctx =>
{
- FileInfo file = new(filename);
- if (!file.Name.StartsWith('.') && !IsBannedExtension(file.Name, bannedExtensions))
+
+ var tsk = new ProgressTaskSettings { MaxValue = Directory.GetFiles(PhotosPath).Length, AutoStart = true };
+ var task1 = ctx.AddTask("Photos Processed", tsk);
+ foreach (string filename in Directory.GetFiles(PhotosPath))
{
- Console.WriteLine($"{file.Name}");
- //Path.GetFileName(filename);
+ FileInfo file = new(filename);
+ if (!file.Name.StartsWith('.') && !IsBannedExtension(file.Name, bannedExtensions))
+ {
+ //Console.WriteLine($"{file.Name}");
+ //Path.GetFileName(filename);
if (IsBadFilename(file.Name))
{
badFileNotifications.Add($"Bad Filename: {file}");
- Console.WriteLine($"Bad Filename: {file.Name}");
+ //Console.WriteLine($"Bad Filename: {file.Name}");
sqlFile.WriteLine(FixBadFilenameAndUpdateRecord(file, videoExtensions, PhotosTable));
- } else {;
+ }
+ else
+ {
+ ;
sqlFile.WriteLine(UpdateRecord(file, videoExtensions, PhotosTable));
}
- Console.WriteLine("Processed: " + file.Name);
+ //Console.WriteLine("Processed: " + file.Name);
}
+ task1.Increment(1.0);
}
-
+ });
foreach (var item in badFileNotifications)
{
@@ -290,4 +312,60 @@ namespace PhotosImporter
}
}
+ public class CreateLibraryCommand: ConsoleCommand
+ {
+ private const int Success = 0;
+ private const int Failure = 2;
+
+ public string PhotosPath { get; set; }
+ public string PhotosTable { get; set; }
+ public bool Force { get; set; }
+ public CreateLibraryCommand()
+ {
+ // Register the actual command with a simple (optional) description.
+ IsCommand("create", "Create Library");
+
+ // Add a longer description for the help on that specific command.
+ HasLongDescription("This can be used to quickly read a file's contents " +
+ "while optionally stripping out the ',' character.");
+
+ // Required options/flags, append '=' to obtain the required value.
+ HasRequiredOption("p|path=", "Path", p => PhotosPath = p);
+ HasRequiredOption("t|table=", "Table", t => PhotosTable = t);
+
+ HasRequiredOption("f|force=", "Force", f => Force = false);
+
+
+ // Optional options/flags, append ':' to obtain an optional value, or null if not specified.
+ //HasOption("s|strip:", "Strips ',' from the file before writing to output.",
+ // t => StripCommaCharacter = t == null ? true : Convert.ToBoolean(t));
+ }
+
+ public override int Run(string[] remainingArguments)
+ {
+ using (OdbcConnection connection = new OdbcConnection("DSN=photos"))
+ {
+ connection.Open();
+
+ string query = $"SHOW TABLES like \"{PhotosTable}\";";
+ OdbcCommand command = new OdbcCommand(query, connection);
+
+ int exists = command.ExecuteNonQuery();
+
+ if ( exists > 0)
+ {
+ Console.WriteLine("Library already exists!");
+ return Failure;
+ } else
+ {
+ var ggg = new DirectoryInfo(PhotosPath).FullName;
+
+ new OdbcCommand($"CREATE TABLE {PhotosTable} LIKE template;", connection).ExecuteNonQuery();
+ new OdbcCommand($"INSERT INTO meta (db, path) VALUES (\"{PhotosTable}\", \"{ggg}\");",connection).ExecuteNonQuery();
+ Console.WriteLine($"Created Library \"{PhotosTable}\"");
+ return Success;
+ }
+ }
+ }
+ }
}
\ No newline at end of file