Initial commit

This commit is contained in:
Fey 2025-12-22 17:17:16 +01:00
commit 90dba0c6d3
10 changed files with 429 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -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

View File

@ -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();
}
}
}

133
azupack_flac/ProgramFlac.cs Normal file
View File

@ -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<FileInfo> 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<FileInfo> 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;
}
}
}

View File

@ -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\""
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>false</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TagLibSharp" Version="2.3.0" />
</ItemGroup>
</Project>

View File

@ -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();
}
}
}

129
azupack_mp3/ProgramMp3.cs Normal file
View File

@ -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<FileInfo> 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<FileInfo> 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;
}
}
}

View File

@ -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\""
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>false</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TagLibSharp" Version="2.3.0" />
</ItemGroup>
</Project>

4
workstation_tools.slnx Normal file
View File

@ -0,0 +1,4 @@
<Solution>
<Project Path="azupack_flac/azupack_flac.csproj" />
<Project Path="azupack_mp3/azupack_mp3.csproj" />
</Solution>