HOME 7 meses atrás
pai
commit
c4f16930c1

+ 5 - 1
FNZCM/FNZCM.BlazorWasm/Program.cs

@@ -3,6 +3,7 @@ using FNZCM.BlazorWasm.Helpers;
 using FNZCM.BlazorWasm.UI.Views.Default;
 using Microsoft.AspNetCore.Components.Web;
 using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
+using Microsoft.Extensions.DependencyInjection;
 using System.Text;
 
 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
@@ -15,7 +16,10 @@ builder.Services.AddScoped(sp =>
     var http = new HttpClient();
 
 #if DEBUG
-    http.BaseAddress = new Uri("http://fnz-server");
+    http.BaseAddress = new Uri(
+        //"http://fnz-server"
+        "http://d3ns2.topcl.net:38964"
+        );
 #else
     var NavManager = sp.GetService<Microsoft.AspNetCore.Components.NavigationManager>();
     var ba = new Uri($"{NavManager.ToAbsoluteUri("/").GetLeftPart(UriPartial.Scheme | UriPartial.Authority)}");

+ 14 - 0
FNZCM/FNZCM.FolderTool/FNZCM.FolderTool.csproj

@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="TagLibSharp" Version="2.3.0" />
+  </ItemGroup>
+
+</Project>

+ 119 - 0
FNZCM/FNZCM.FolderTool/Program.cs

@@ -0,0 +1,119 @@
+// See https://aka.ms/new-console-template for more information
+
+using System.Globalization;
+using System.Reflection.Emit;
+using TagLib;
+
+Console.WriteLine("Hello, World!");
+
+Environment.CurrentDirectory = "TargetFolder";
+var dirs = Directory.GetDirectories(".").Select(p => p.Substring(2)).Where(p => p.StartsWith("[") == false).ToArray();
+
+foreach (var dir in dirs)
+{
+    Console.WriteLine();
+
+    var firstFile = Directory.GetFiles(dir, "*.flac").FirstOrDefault();
+    if (firstFile == null)
+    {
+        if (Directory.GetFiles(dir).Length == 0)
+        {
+            Grey($"* delete empty dir `{dir}'");
+            Directory.Delete(dir, false);
+            continue;
+        }
+        Warn($"* Warn: flac file not found in top-level dir, its in sub dir? `{dir}'");
+        continue;
+    }
+
+    var tag = TagLib.File.Create(firstFile);
+    var xc = (TagLib.Ogg.XiphComment)tag.GetTag(TagTypes.Xiph);
+    var v = xc.GetField("DATE").FirstOrDefault()?.Trim();
+    if (false == DateTime.TryParseExact(v, "yyyy.MM.dd", null, DateTimeStyles.None, out var dt))
+    {
+        Warn($"* Warn: unable to get date from `{firstFile}' in `{dir}'");
+        continue;
+    }
+
+    tag.Dispose();
+
+    var parts = dir.Split(' ');
+
+    if (parts.Length <= 2)
+    {
+        Warn($"* Warn: unable to process folder name for `{dir}'");
+        continue;
+    }
+
+    var last1 = parts[^1];
+    var last2 = parts[^2];
+
+    string prefix;
+    string remain;
+    if (last2.StartsWith('[') && last2.EndsWith("]") && last1.StartsWith('(') && last1.EndsWith(')'))
+    {
+        var evt = last1;
+        var label = last2;
+        prefix = $"[{dt:yyMMdd}] [{evt[1..^1]}] {label}";
+        remain = string.Join(" ", parts[..^2]);
+    }
+    else if (last1.StartsWith('[') && last1.EndsWith(']'))
+    {
+        var label = last1;
+
+        prefix = $"[{dt:yyMMdd}] {label}";
+        remain = string.Join(" ", parts[..^1]);
+    }
+    else
+    {
+        prefix = $"[{dt:yyMMdd}]";
+        remain = string.Join(" ", parts);
+
+        Warn("* Warn: unable to get label");
+    }
+
+    Console.WriteLine($"from >  {string.Empty.PadLeft(prefix.Length, ' ')}{dir}");
+
+    Console.Write($"to   > {prefix} ");
+    HiLight($"{remain}");
+    Console.WriteLine();
+
+    var final = prefix + " " + remain;
+
+    try
+    {
+        Directory.Move(dir, final);
+    }
+    catch (Exception e)
+    {
+        Error("Err:" + e.Message);
+    }
+}
+
+
+Console.WriteLine();
+Console.Write("Finished. Press ENTER to exit");
+Console.ReadLine();
+
+
+static void HiLight(string msg) => ForegroundColor(ConsoleColor.Green, delegate { Console.Write(msg); });
+
+static void Grey(string msg) => ForegroundColor(ConsoleColor.DarkGray, delegate { Console.WriteLine(msg); });
+
+static void Warn(string msg) => ForegroundColor(ConsoleColor.Yellow, delegate { Console.WriteLine(msg); });
+
+static void Error(string msg) => ForegroundColor(ConsoleColor.Red, delegate { Console.WriteLine(msg); });
+
+static void ForegroundColor(ConsoleColor fg, Action action)
+{
+    var oldColor = Console.ForegroundColor;
+    Console.ForegroundColor = fg;
+    try
+    {
+        action();
+    }
+    finally
+    {
+        Console.ForegroundColor = oldColor;
+    }
+}

+ 6 - 0
FNZCM/FNZCM.sln

@@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FNZCM.Shared", "FNZCM.Share
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FNZCM.BlazorWasm", "FNZCM.BlazorWasm\FNZCM.BlazorWasm.csproj", "{6610DBEA-B1FC-44E2-AC16-4E482C19E251}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNZCM.FolderTool", "FNZCM.FolderTool\FNZCM.FolderTool.csproj", "{7DF8C95A-4C5F-4377-AE97-E1FA99E0206E}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -45,6 +47,10 @@ Global
 		{6610DBEA-B1FC-44E2-AC16-4E482C19E251}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{6610DBEA-B1FC-44E2-AC16-4E482C19E251}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{6610DBEA-B1FC-44E2-AC16-4E482C19E251}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7DF8C95A-4C5F-4377-AE97-E1FA99E0206E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7DF8C95A-4C5F-4377-AE97-E1FA99E0206E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7DF8C95A-4C5F-4377-AE97-E1FA99E0206E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7DF8C95A-4C5F-4377-AE97-E1FA99E0206E}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE