|
@@ -33,7 +33,7 @@ namespace BatchProcess
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- Console.WriteLine($"ERROR:{e.GetType().Name},{e.Message}");
|
|
|
+ Console.WriteLine($"ERROR:{e}");
|
|
|
}
|
|
|
|
|
|
Console.WriteLine();
|
|
@@ -52,28 +52,30 @@ namespace BatchProcess
|
|
|
private const string OP_EMB_LRC = "emblrc";
|
|
|
private const string OP_CONVERT_FLAC_TO_AAC = "convert_flac_to_aac";
|
|
|
private const string OP_CONVERT_LIB_FLAC_TO_AAC = "convert_lib_flac_to_aac";
|
|
|
+ private const string OP_CONVERT_LIB_FLAC_TO_AAC_IN_DIR = "convert_lib_flac_to_aac_in_dir";
|
|
|
|
|
|
private static void RealMain(string[] args)
|
|
|
{
|
|
|
if (0 == args.Length)
|
|
|
{
|
|
|
- Console.WriteLine($"Usage: {Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase)} <op> [args...]");
|
|
|
+ Console.WriteLine($"Usage: {Path.GetFileName(AppDomain.CurrentDomain.FriendlyName)} <op> [args...]");
|
|
|
Console.WriteLine($"Prefix ops:");
|
|
|
Console.WriteLine($" * --no-pause");
|
|
|
Console.WriteLine($" Disable enter key to exit");
|
|
|
Console.WriteLine($"Available ops:");
|
|
|
Console.WriteLine($" * {OP_COPY} <sourcePath> <targetPath>");
|
|
|
Console.WriteLine($" Copy tags from source to target (replace)");
|
|
|
+ Console.WriteLine($" Note: Only standard tags and front cover");
|
|
|
Console.WriteLine($" * {OP_EMB_LRC} <inputPath> <lrcPath> <outputPath>");
|
|
|
Console.WriteLine($" Embed lyrics into file(utf8)");
|
|
|
Console.WriteLine($" * {OP_EMB_COVER}|{OP_EMB_COVER_IF_NOT_EMBEDDED} <inputPath> <coverPath> [outputPath] [mime-type]");
|
|
|
Console.WriteLine($" Embed cover into file, default mine-type is {MediaTypeNames.Image.Jpeg}");
|
|
|
Console.WriteLine($" * {OP_EMB_COVER_IF_NOT_EMBEDDED_COVER_DOT_JPG} <inputPath>");
|
|
|
Console.WriteLine($" Embed cover into file if not embedded, same folder cover.jpg");
|
|
|
- Console.WriteLine($" * {OP_DIR_EMB_COVER_MP3} <inputDir> <outputDir> -- lookup dir, embed same file name jpg/jpeg into mp3");
|
|
|
+ Console.WriteLine($" * {OP_DIR_EMB_COVER_MP3} <inputDir> <outputDir>");
|
|
|
Console.WriteLine($" Lookup dir, embed same file name jpg/jpeg into mp3");
|
|
|
Console.WriteLine($" Embed abc.jpg or abc.jpeg into abc.mp3 and save a copy to output dir.");
|
|
|
- Console.WriteLine($" * {OP_DIR_EMB_COVER_M4A} <inputDir> <outputDir> -- lookup dir, embed same file name jpg/jpeg into m4a");
|
|
|
+ Console.WriteLine($" * {OP_DIR_EMB_COVER_M4A} <inputDir> <outputDir>");
|
|
|
Console.WriteLine($" Lookup dir, embed same file name jpg/jpeg into m4a");
|
|
|
Console.WriteLine($" Embed abc.jpg or abc.jpeg into abc.m4a and save a copy to output dir.");
|
|
|
Console.WriteLine($" * {OP_CONVERT_FLAC_TO_AAC} <inputPath> <outputPath> [q value]");
|
|
@@ -82,7 +84,9 @@ namespace BatchProcess
|
|
|
Console.WriteLine($" Convert to aac and copy tags to output, default q is 1.0");
|
|
|
Console.WriteLine($" inputDir/Album/Track.flac -> outputDir/Album/Track.m4a");
|
|
|
Console.WriteLine($" Also copy inputDir/Album/cover.jpg to outDir/Album/cover.jpg if found");
|
|
|
-
|
|
|
+ Console.WriteLine($" * {OP_CONVERT_LIB_FLAC_TO_AAC_IN_DIR} <libDir> [q value]");
|
|
|
+ Console.WriteLine($" Convert to aac and copy tags to output, default q is 1.0");
|
|
|
+ Console.WriteLine($" libDir/Album/Track.flac -> libDir/Album/AAC_Q1.00/Track.m4a");
|
|
|
Console.WriteLine($"");
|
|
|
Console.WriteLine($" + More on demand");
|
|
|
return;
|
|
@@ -112,11 +116,45 @@ namespace BatchProcess
|
|
|
|
|
|
case OP_CONVERT_FLAC_TO_AAC: ConvertFlacToAac(argsToOp); break;
|
|
|
case OP_CONVERT_LIB_FLAC_TO_AAC: ConvertLibFlacToAac(argsToOp); break;
|
|
|
+ case OP_CONVERT_LIB_FLAC_TO_AAC_IN_DIR: ConvertLibFlacToAacInDir(argsToOp); break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// impl
|
|
|
|
|
|
+ private static void ConvertLibFlacToAacInDir(string[] args)
|
|
|
+ {
|
|
|
+ if (args.Length < 1) throw new ArgumentException("args least need 1");
|
|
|
+ var libDir = args[0];
|
|
|
+
|
|
|
+ if (false == Directory.Exists(libDir)) throw new DirectoryNotFoundException($"lib dir `{libDir}' not found.");
|
|
|
+
|
|
|
+ var q = args.Length > 1 && float.TryParse(args[1], out var tq) && tq is >= 0 and <= 1
|
|
|
+ ? tq
|
|
|
+ : 1.0;
|
|
|
+
|
|
|
+ foreach (var albDir in Directory.GetDirectories(libDir))
|
|
|
+ {
|
|
|
+ var outAlbDir = Path.Combine(albDir, $"AAC_Q{q:N2}");
|
|
|
+
|
|
|
+ if (false == Directory.Exists(outAlbDir))
|
|
|
+ {
|
|
|
+ Console.WriteLine($"Create dir:{outAlbDir}");
|
|
|
+ Directory.CreateDirectory(outAlbDir);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var flacPath in Directory.GetFiles(albDir, "*.flac"))
|
|
|
+ {
|
|
|
+ var outM4APath = Path.Combine(outAlbDir, Path.ChangeExtension(Path.GetFileName(flacPath), ".m4a"));
|
|
|
+ Console.WriteLine(
|
|
|
+ ConvertFlacToAac(new[] {flacPath, outM4APath, $"{q}"})
|
|
|
+ ? $"Convert OK. -> {outM4APath}"
|
|
|
+ : $"Exist, Skipped. {outM4APath}"
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static void ConvertLibFlacToAac(string[] args)
|
|
|
{
|
|
|
if (args.Length < 2) throw new ArgumentException("args least need 2");
|