Add DMI field support

This commit is contained in:
Matt Nadareski
2026-11-11 22:40:17 +01:00
parent fd52331d5b
commit 126bc4eb4d
10 changed files with 33 additions and 1 deletions

View File

@@ -109,6 +109,7 @@ namespace SabreTools.RedumpLib.Test.Data
BCA = "BCA",
PIC = "PIC",
PICIdentifier = "XB4",
DMI = "DMI",
Cuesheet = "Cuesheet",
Dat = "Datfile",
},

View File

@@ -23,6 +23,7 @@ namespace SabreTools.RedumpLib.Test.Endpoints
[InlineData(DiscSubpath.Edit, "https://redump.info/disc/1/edit")]
[InlineData(DiscSubpath.SBI, "https://redump.info/disc/1/sbi")]
[InlineData(DiscSubpath.LSD, "https://redump.info/disc/1/lsd")]
[InlineData(DiscSubpath.DMI, "https://redump.info/disc/1/dmi")]
public void BuildUrl_Subpath_Builds(DiscSubpath? subpath, string expected)
{
var endpoint = new RedumpLib.Endpoints.Disc

View File

@@ -105,6 +105,7 @@ namespace SabreTools.RedumpLib.Test.Tools
BCA = "BCA",
PIC = "PIC",
PICIdentifier = "XB4",
DMI = "DMI",
Cuesheet = "Cuesheet",
Dat = "Datfile",
},
@@ -554,7 +555,7 @@ namespace SabreTools.RedumpLib.Test.Tools
[Fact]
public void FormatOutputData_DumpMetadataSection_Formatted()
{
string expected = "Dump Metadata:\n\tComments: XXXXXX\n\tContents: XXXXXX\n\tProtection: XXXXXX\n\tSector Ranges: XXXXXX\n\tSBI: XXXXXX\n\tPrimary Volume Descriptor (PVD): XXXXXX\n\tHeader: XXXXXX\n\tBurst Cutting Area (BCA): XXXXXX\n\tPermanent Information & Control (PIC): XXXXXX\n\tCuesheet: XXXXXX\n\tDat:\n\nXXXXXX\n\n\n";
string expected = "Dump Metadata:\n\tComments: XXXXXX\n\tContents: XXXXXX\n\tProtection: XXXXXX\n\tSector Ranges: XXXXXX\n\tSBI: XXXXXX\n\tPrimary Volume Descriptor (PVD): XXXXXX\n\tHeader: XXXXXX\n\tBurst Cutting Area (BCA): XXXXXX\n\tPermanent Information & Control (PIC): XXXXXX\n\tDMI: XXXXXX\n\tCuesheet: XXXXXX\n\tDat:\n\nXXXXXX\n\n\n";
var builder = new StringBuilder();
DumpMetadataSection? section = new()
@@ -568,6 +569,7 @@ namespace SabreTools.RedumpLib.Test.Tools
Header = "XXXXXX",
BCA = "XXXXXX",
PIC = "XXXXXX",
DMI = "XXXXXX",
Cuesheet = "XXXXXX",
Dat = "XXXXXX",
};

View File

@@ -143,6 +143,7 @@ namespace SabreTools.RedumpLib.Data
DiscSubpath.History,
DiscSubpath.SBI,
DiscSubpath.LSD,
DiscSubpath.DMI,
];
#endregion

View File

@@ -61,6 +61,9 @@ namespace SabreTools.RedumpLib.Data
[HumanReadable(LongName = "LSD", ShortName = "lsd")]
LSD = 5,
[HumanReadable(LongName = "DMI", ShortName = "dmi")]
DMI = 6,
}
/// <summary>

View File

@@ -56,6 +56,9 @@ namespace SabreTools.RedumpLib.Data.Sections
[JsonProperty(PropertyName = "pic_identifier", NullValueHandling = NullValueHandling.Ignore)]
public string? PICIdentifier { get; set; }
[JsonProperty(PropertyName = "dmi", NullValueHandling = NullValueHandling.Ignore)]
public string? DMI { get; set; }
[JsonProperty(PropertyName = "cue", NullValueHandling = NullValueHandling.Ignore)]
public string? Cuesheet { get; set; }
@@ -102,6 +105,7 @@ namespace SabreTools.RedumpLib.Data.Sections
BCA = this.BCA,
PIC = this.PIC,
PICIdentifier = this.PICIdentifier,
DMI = this.DMI,
Cuesheet = this.Cuesheet,
Dat = this.Dat,
};

View File

@@ -72,6 +72,7 @@
public const string HeaderField = "Header";
public const string BCAField = "Burst Cutting Area (BCA)";
public const string PICField = "Permanent Information & Control (PIC)";
public const string DMIField = "DMI";
public const string CuesheetField = "Cuesheet";
public const string DatField = "Dat";

View File

@@ -32,6 +32,7 @@ namespace SabreTools.RedumpLib.Endpoints
case DiscSubpath.Edit:
case DiscSubpath.SBI:
case DiscSubpath.LSD:
case DiscSubpath.DMI:
ub.Path += $"/{Subpath.ShortName()}";
break;

View File

@@ -424,6 +424,7 @@ namespace SabreTools.RedumpLib.Tools
AddIfExists(output, Template.HeaderField, section.Header, 1);
AddIfExists(output, Template.BCAField, section.BCA, 1);
AddIfExists(output, Template.PICField, section.PIC, 1);
AddIfExists(output, Template.DMIField, section.DMI, 1);
AddIfExists(output, Template.CuesheetField, section.Cuesheet, 1);
AddIfExists(output, Template.DatField, section.Dat + "\n", 1);
}

View File

@@ -1184,6 +1184,23 @@ namespace SabreTools.RedumpLib.Web
}
}
// DMI
if ((discSubpaths is null || Array.Exists(discSubpaths, s => s is DiscSubpath.DMI)) && discPage.Contains($"<a href=\"/disc/{id}/dmi\""))
{
var subEndpoint = new Endpoints.Disc
{
Id = id,
Subpath = DiscSubpath.DMI,
};
string uri = endpoint.BuildUrl();
string? remoteName = await DownloadFile(uri, Path.Combine(paddedIdDir, $"{paddedId}.dmi"));
if (!IgnoreErrors && remoteName is null)
{
if (Debug) ReportDebug($"Downloading DMI for {id} failed!");
return false;
}
}
// LSD
if ((discSubpaths is null || Array.Exists(discSubpaths, s => s is DiscSubpath.LSD)) && discPage.Contains($"<a href=\"/disc/{id}/lsd\""))
{