commit 90dba0c6d36b275454fcd229e3f1fcc9f4a311b9 Author: Fey Date: Mon Dec 22 17:17:16 2025 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bb932c --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +/.vs/ProjectEvaluation +/.vs/workstation_tools.slnx/DesignTimeBuild +/.vs/workstation_tools.slnx/FileContentIndex +/.vs/workstation_tools.slnx/v18 +/azupack_flac/bin/Debug/net10.0-windows +/azupack_flac/obj/Debug/net10.0-windows +/azupack_flac/obj/Debug/net10.0 +/azupack_flac/obj +/azupack_mp3/bin/Debug/net10.0-windows +/azupack_mp3/obj/Debug/net10.0-windows +/azupack_mp3/obj diff --git a/azupack_flac/AzupackMeta.cs b/azupack_flac/AzupackMeta.cs new file mode 100644 index 0000000..5466bc3 --- /dev/null +++ b/azupack_flac/AzupackMeta.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml.Serialization; + +namespace azupack_flac +{ + public class AzupackMeta + { + public AzupackMeta() + { + this.Guid = Guid.NewGuid(); + this.Timestamp = DateTime.Now; + this.MachineName = Environment.MachineName; + this.UserName = Environment.UserName; + + System.Reflection.Assembly assembly = this.GetType().Assembly; + System.Reflection.AssemblyName assemblyName = assembly.GetName(); + this.AssemblyName = assemblyName.FullName; + } + + public Guid Guid { get; set; } + public DateTime Timestamp { get; set; } + public string MachineName { get; set; } + + private string _userName; + public string UserName + { + get => _userName; + set + { + if (value.Equals("Sascha Schiemann")) + { + value = "Feyris-Tan"; + } + _userName = value; + } + } + + public string AssemblyName { get; set; } + + public override string ToString() + { + StringWriter stringWriter = new StringWriter(); + XmlSerializer xs = new XmlSerializer(typeof(AzupackMeta)); + xs.Serialize(stringWriter, this); + stringWriter.Flush(); + return stringWriter.ToString(); + } + } +} diff --git a/azupack_flac/ProgramFlac.cs b/azupack_flac/ProgramFlac.cs new file mode 100644 index 0000000..3fc2a39 --- /dev/null +++ b/azupack_flac/ProgramFlac.cs @@ -0,0 +1,133 @@ +using System.Diagnostics; + +namespace azupack_flac +{ + internal class Program + { + static void Main(string[] args) + { + if (args.Length == 0) + { + MessageBox.Show("Hey, gimme something to work with!"); + return; + } + if (args.Length == 1) + { + FileInfo fi = new FileInfo(args[0]); + string fileExtension = Path.GetExtension(fi.Name); + if (fileExtension.ToLower().Equals(".flac")) + { + TagLib.File file = TagLib.File.Create(fi.FullName); + TagLib.Ogg.XiphComment tag = (TagLib.Ogg.XiphComment)file.GetTag(TagLib.TagTypes.Xiph); + string[] strings = tag.ToArray(); + string joined = String.Join("\n", strings); + MessageBox.Show(joined); + return; + } + else + { + MessageBox.Show("What am I supposed to do with a single FLAC file?"); + return; + } + } + + List fileInfos = args.Select(x => new FileInfo(x)).ToList(); + if (!fileInfos.Any(x => Path.GetExtension(x.Name).ToLower().Equals(".wav"))) + { + MessageBox.Show("No wav file!"); + return; + } + + FileInfo wavFile = fileInfos.Find(x => Path.GetExtension(x.Name).ToLower().Equals(".wav")); + fileInfos.Remove(wavFile); + + List jpgFiles = fileInfos.Where(x => Path.GetExtension(x.FullName).ToLower().Equals(".jpg")).ToList(); + jpgFiles.Sort((x, y) => x.Name.CompareTo(y.Name)); + fileInfos.RemoveAll(x => jpgFiles.Contains(x)); + + ProcessStartInfo processStartInfo = new ProcessStartInfo(); + processStartInfo.FileName = "C:\\FT\\flac.exe"; + processStartInfo.Arguments = String.Format("-8 \"{0}\"", wavFile.FullName); + processStartInfo.WorkingDirectory = wavFile.Directory.FullName; + Process? process = Process.Start(processStartInfo); + process.WaitForExit(); + + FileInfo flacFile = new FileInfo(Path.ChangeExtension(wavFile.FullName, ".flac")); + if (!flacFile.Exists) + { + MessageBox.Show("Failed to generate FLAC file."); + return; + } + + TagLib.File taglibFile = TagLib.File.Create(flacFile.FullName); + TagLib.Ogg.XiphComment tag2 = (TagLib.Ogg.XiphComment)taglibFile.GetTag(TagLib.TagTypes.Xiph); + bool cueSet = false; + + foreach (FileInfo fi in fileInfos) + { + string extension = Path.GetExtension(fi.FullName).ToLowerInvariant(); + switch (extension) + { + case ".cue": + string v = File.ReadAllText(fi.FullName); + if (!cueSet) + { + tag2.SetField("CUESHEET", v); + tag2.SetField("AZUSA_CLEAN_CUE", v); + cueSet = true; + } + else + { + tag2.SetField("AZUSA_ALT_CUE", v); + } + break; + case ".md5": + string v1 = File.ReadAllText(fi.FullName); + tag2.SetField("AZUSA_MD5", v1); + break; + case ".ibg": + string v2 = File.ReadAllText(fi.FullName); + tag2.SetField("AZUSA_IBG", v2); + break; + case ".log": + string v3 = File.ReadAllText(fi.FullName); + tag2.SetField("AZUSA_LOG", v3); + break; + default: + MessageBox.Show(String.Format("Don't know what to do with a {0} file.", fi.FullName)); + return; + } + } + + TagLib.PictureType[] types = new TagLib.PictureType[] { TagLib.PictureType.FrontCover, TagLib.PictureType.BackCover, TagLib.PictureType.Artist, TagLib.PictureType.Media, TagLib.PictureType.FileIcon }; + TagLib.Picture[] pictures = new TagLib.Picture[jpgFiles.Count]; + for (int i = 0; i < jpgFiles.Count; i++) + { + TagLib.Picture picture = new TagLib.Picture(jpgFiles[i].FullName); + picture.MimeType = "image/jpeg"; + picture.Type = types[i]; + pictures[i] = picture; + } + + taglibFile.Tag.Pictures = pictures; + tag2.SetField("AZUPACK", new AzupackMeta().ToString()); + uint? cdNumber = GetCdNumber(flacFile.FullName); + if (cdNumber != null) + { + taglibFile.Tag.Disc = cdNumber.Value; + } + taglibFile.Save(); + } + + private static uint? GetCdNumber(string name) + { + for (uint i = 99; i > 0; i--) + { + string fname = String.Format("CD{0}", i); + if (name.Contains(fname)) + return i; + } + return null; + } + } +} diff --git a/azupack_flac/Properties/launchSettings.json b/azupack_flac/Properties/launchSettings.json new file mode 100644 index 0000000..49569fa --- /dev/null +++ b/azupack_flac/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "azupack_flac": { + "commandName": "Project", + "commandLineArgs": "\"D:\\RIPs\\HnG\\ヒカルの碁 主題歌全集 (ベスト オブ ヒカルの碁) <CCCD>.cue\"\r\n\"D:\\RIPs\\HnG\\ヒカルの碁 主題歌全集 (ベスト オブ ヒカルの碁) <CCCD>.log\"\r\n\"D:\\RIPs\\HnG\\ヒカルの碁 主題歌全集 (ベスト オブ ヒカルの碁) <CCCD>.wav\"\r\n\"D:\\RIPs\\HnG\\hng.jpg\"\r\n\"D:\\RIPs\\HnG\\ - ヒカルの碁 主題歌全集 (ベスト オブ ヒカルの碁) <CCCD>.jpg\"\r\n\"D:\\RIPs\\HnG\\Best of Hikaru no Go.cue\"\r\n\"D:\\RIPs\\HnG\\Best of Hikaru no Go.md5\"\r\n\"D:\\RIPs\\HnG\\PIONEER_BD-RW_BDR-209D_1.10_MONTAG-15-DEZEMBER-2025_22-51_N-A.ibg\"" + } + } +} \ No newline at end of file diff --git a/azupack_flac/azupack_flac.csproj b/azupack_flac/azupack_flac.csproj new file mode 100644 index 0000000..04c9c59 --- /dev/null +++ b/azupack_flac/azupack_flac.csproj @@ -0,0 +1,17 @@ + + + + Exe + net10.0-windows + enable + enable + false + true + true + + + + + + + diff --git a/azupack_mp3/AzupackMeta.cs b/azupack_mp3/AzupackMeta.cs new file mode 100644 index 0000000..5466bc3 --- /dev/null +++ b/azupack_mp3/AzupackMeta.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml.Serialization; + +namespace azupack_flac +{ + public class AzupackMeta + { + public AzupackMeta() + { + this.Guid = Guid.NewGuid(); + this.Timestamp = DateTime.Now; + this.MachineName = Environment.MachineName; + this.UserName = Environment.UserName; + + System.Reflection.Assembly assembly = this.GetType().Assembly; + System.Reflection.AssemblyName assemblyName = assembly.GetName(); + this.AssemblyName = assemblyName.FullName; + } + + public Guid Guid { get; set; } + public DateTime Timestamp { get; set; } + public string MachineName { get; set; } + + private string _userName; + public string UserName + { + get => _userName; + set + { + if (value.Equals("Sascha Schiemann")) + { + value = "Feyris-Tan"; + } + _userName = value; + } + } + + public string AssemblyName { get; set; } + + public override string ToString() + { + StringWriter stringWriter = new StringWriter(); + XmlSerializer xs = new XmlSerializer(typeof(AzupackMeta)); + xs.Serialize(stringWriter, this); + stringWriter.Flush(); + return stringWriter.ToString(); + } + } +} diff --git a/azupack_mp3/ProgramMp3.cs b/azupack_mp3/ProgramMp3.cs new file mode 100644 index 0000000..5cd856d --- /dev/null +++ b/azupack_mp3/ProgramMp3.cs @@ -0,0 +1,129 @@ +using System.Buffers.Text; +using System.Diagnostics; + +namespace azupack_flac +{ + internal class Program + { + static void Main(string[] args) + { + if (args.Length == 0) + { + MessageBox.Show("Hey, gimme something to work with!"); + return; + } + if (args.Length == 1) + { + FileInfo fi = new FileInfo(args[0]); + string fileExtension = Path.GetExtension(fi.Name); + if (fileExtension.ToLower().Equals(".mp3")) + { + TagLib.File file = TagLib.File.Create(fi.FullName); + TagLib.Id3v2.Tag tag = (TagLib.Id3v2.Tag)file.GetTag(TagLib.TagTypes.Id3v2); + return; + } + else + { + MessageBox.Show("What am I supposed to do with a single FLAC file?"); + return; + } + } + + List fileInfos = args.Select(x => new FileInfo(x)).ToList(); + if (!fileInfos.Any(x => Path.GetExtension(x.Name).ToLower().Equals(".wav"))) + { + MessageBox.Show("No wav file!"); + return; + } + + FileInfo wavFile = fileInfos.Find(x => Path.GetExtension(x.Name).ToLower().Equals(".wav")); + fileInfos.Remove(wavFile); + + List jpgFiles = fileInfos.Where(x => Path.GetExtension(x.FullName).ToLower().Equals(".jpg")).ToList(); + jpgFiles.Sort((x, y) => x.Name.CompareTo(y.Name)); + fileInfos.RemoveAll(x => jpgFiles.Contains(x)); + + ProcessStartInfo processStartInfo = new ProcessStartInfo(); + processStartInfo.FileName = "C:\\FT\\lame.exe"; + processStartInfo.Arguments = String.Format("\"{0}\"", wavFile.FullName); + processStartInfo.WorkingDirectory = wavFile.Directory.FullName; + Process? process = Process.Start(processStartInfo); + process.WaitForExit(); + + FileInfo flacFile = new FileInfo(Path.ChangeExtension(wavFile.FullName, ".mp3")); + if (!flacFile.Exists) + { + MessageBox.Show("Failed to generate MP3 file."); + return; + } + + TagLib.File taglibFile = TagLib.File.Create(flacFile.FullName); + TagLib.Id3v2.Tag tag2 = (TagLib.Id3v2.Tag)taglibFile.GetTag(TagLib.TagTypes.Id3v2); + + foreach (FileInfo fi in fileInfos) + { + string extension = Path.GetExtension(fi.FullName).ToLowerInvariant(); + TagLib.Id3v2.UserTextInformationFrame frame; + + switch (extension) + { + case ".cue": + frame = new TagLib.Id3v2.UserTextInformationFrame("AZUSA_CLEAN_CUE"); + frame.Text = new string[] { File.ReadAllText(fi.FullName) }; + break; + case ".md5": + frame = new TagLib.Id3v2.UserTextInformationFrame("AZUSA_MD5"); + frame.Text = new string[] { File.ReadAllText(fi.FullName) }; + break; + case ".ibg": + frame = new TagLib.Id3v2.UserTextInformationFrame("AZUSA_IBG"); + frame.Text = new string[] { File.ReadAllText(fi.FullName) }; + break; + case ".cdt": + byte[] ibgBytes = File.ReadAllBytes(fi.FullName); + frame = new TagLib.Id3v2.UserTextInformationFrame("AZUSA_CDT"); + frame.Text = new string[] { Convert.ToBase64String(ibgBytes) }; + break; + default: + MessageBox.Show(String.Format("Don't know what to do with a {0} file.", fi.FullName)); + return; + } + frame.TextEncoding = TagLib.StringType.UTF8; + tag2.AddFrame(frame); + } + + TagLib.PictureType[] types = new TagLib.PictureType[] { TagLib.PictureType.FrontCover, TagLib.PictureType.BackCover, TagLib.PictureType.Artist, TagLib.PictureType.Media, TagLib.PictureType.FileIcon }; + TagLib.Picture[] pictures = new TagLib.Picture[jpgFiles.Count]; + for (int i = 0; i < jpgFiles.Count; i++) + { + TagLib.Picture picture = new TagLib.Picture(jpgFiles[i].FullName); + picture.MimeType = "image/jpeg"; + picture.Type = types[i]; + pictures[i] = picture; + } + + taglibFile.Tag.Pictures = pictures; + TagLib.Id3v2.UserTextInformationFrame azupackFrame = new TagLib.Id3v2.UserTextInformationFrame("AZUPACK"); + azupackFrame.Flags = TagLib.Id3v2.FrameFlags.None; + azupackFrame.Text = new string[] { new AzupackMeta().ToString() }; + tag2.AddFrame(azupackFrame); + uint? cdNumber = GetCdNumber(flacFile.FullName); + if (cdNumber != null) + { + taglibFile.Tag.Disc = cdNumber.Value; + } + taglibFile.Save(); + } + + private static uint? GetCdNumber(string name) + { + for (uint i = 99; i > 0; i--) + { + string fname = String.Format("CD{0}", i); + if (name.Contains(fname)) + return i; + } + return null; + } + } +} diff --git a/azupack_mp3/Properties/launchSettings.json b/azupack_mp3/Properties/launchSettings.json new file mode 100644 index 0000000..1f4cb73 --- /dev/null +++ b/azupack_mp3/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "azupack_flac": { + "commandName": "Project", + "commandLineArgs": "\"D:\\RIPs\\Die drei - Adventskalender - Gruselige Weihnacht überall - CD1.cue\"\r\n\"D:\\RIPs\\Die drei - Adventskalender - Gruselige Weihnacht überall - CD1.md5\"\r\n\"D:\\RIPs\\PIONEER_BD-RW_BDR-209D_1.10_DONNERSTAG-11-DEZEMBER-2025_23-50_N-A.ibg\"\r\n\"D:\\RIPs\\Die drei - Adventskalender - Gruselige Weihnacht überall - CD1.wav\"\r\n\"D:\\RIPs\\Die drei - Adventskalender - Gruselige Weihnacht überall - CD1.cdt\"" + } + } +} \ No newline at end of file diff --git a/azupack_mp3/azupack_mp3.csproj b/azupack_mp3/azupack_mp3.csproj new file mode 100644 index 0000000..04c9c59 --- /dev/null +++ b/azupack_mp3/azupack_mp3.csproj @@ -0,0 +1,17 @@ + + + + Exe + net10.0-windows + enable + enable + false + true + true + + + + + + + diff --git a/workstation_tools.slnx b/workstation_tools.slnx new file mode 100644 index 0000000..9539eb1 --- /dev/null +++ b/workstation_tools.slnx @@ -0,0 +1,4 @@ + + + +