Be smarter about volume labels

This commit is contained in:
Matt Nadareski
2022-01-20 13:15:53 -08:00
parent 1af9e2c2da
commit 2cdf473dcb
3 changed files with 52 additions and 37 deletions

View File

@@ -47,6 +47,7 @@
- Fix crash on invalid parameters
- Differentiate XMID and XeMID
- Conditionally pull region from Redump
- Be smarter about volume labels
### 2.2 (2021-12-30)
- Fix Saturn header finding

View File

@@ -268,11 +268,10 @@ namespace MPF.Core.Data
if (this.InternalDriveType != Data.InternalDriveType.Optical)
return RedumpSystem.IBMPCcompatible;
// Audio CD
if (this.FormattedVolumeLabel.Equals("Audio CD", StringComparison.OrdinalIgnoreCase))
{
return RedumpSystem.AudioCD;
}
// Check volume labels first
RedumpSystem? systemFromLabel = GetRedumpSystemFromVolumeLabel();
if (systemFromLabel != null)
return systemFromLabel;
// BD-Video
if (Directory.Exists(Path.Combine(drivePath, "BDMV")))
@@ -281,7 +280,7 @@ namespace MPF.Core.Data
return RedumpSystem.BDVideo;
}
// DVD-Audio
// DVD-Audio and DVD-Video
try
{
if (Directory.Exists(Path.Combine(drivePath, "AUDIO_TS"))
@@ -289,19 +288,10 @@ namespace MPF.Core.Data
{
return RedumpSystem.DVDAudio;
}
}
catch { }
// DVD-Video and Xbox
try
{
if (Directory.Exists(Path.Combine(drivePath, "VIDEO_TS"))
else if (Directory.Exists(Path.Combine(drivePath, "VIDEO_TS"))
&& Directory.EnumerateFiles(Path.Combine(drivePath, "VIDEO_TS")).Any())
{
// TODO: Maybe add video track hashes to compare for Xbox and X360?
if (this.FormattedVolumeLabel.StartsWith("SEP13011042", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.MicrosoftXbox;
return RedumpSystem.DVDVideo;
}
}
@@ -364,24 +354,6 @@ namespace MPF.Core.Data
return RedumpSystem.SonyPlayStation;
}
// Sony PlayStation 3
if (this.FormattedVolumeLabel.Equals("PS3VOLUME", StringComparison.OrdinalIgnoreCase))
{
return RedumpSystem.SonyPlayStation3;
}
// Sony PlayStation 4
if (this.FormattedVolumeLabel.Equals("PS4VOLUME", StringComparison.OrdinalIgnoreCase))
{
return RedumpSystem.SonyPlayStation4;
}
// Sony PlayStation 5
if (this.FormattedVolumeLabel.Equals("PS5VOLUME", StringComparison.OrdinalIgnoreCase))
{
return RedumpSystem.SonyPlayStation5;
}
// V.Tech V.Flash / V.Smile Pro
if (File.Exists(Path.Combine(drivePath, "0SYSTEM")))
{
@@ -403,6 +375,49 @@ namespace MPF.Core.Data
return defaultValue;
}
/// <summary>
/// Get the current system from the drive volume label
/// </summary>
/// <returns>The system based on volume label, null if none detected</returns>
public RedumpSystem? GetRedumpSystemFromVolumeLabel()
{
// Audio CD
if (this.FormattedVolumeLabel.Equals("Audio CD", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.AudioCD;
// Microsoft Xbox
if (this.FormattedVolumeLabel.Equals("SEP13011042", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.MicrosoftXbox;
else if (this.FormattedVolumeLabel.Equals("SEP13011042072", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.MicrosoftXbox;
// Microsoft Xbox 360
if (this.FormattedVolumeLabel.Equals("XBOX360", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.MicrosoftXbox360;
else if (this.FormattedVolumeLabel.Equals("XGD2DVD_NTSC", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.MicrosoftXbox360;
// Microsoft Xbox 360 - Too overly broad even if a lot of discs use this
//if (this.FormattedVolumeLabel.Equals("CD_ROM", StringComparison.OrdinalIgnoreCase))
// return RedumpSystem.MicrosoftXbox360; // Also for Xbox One?
//if (this.FormattedVolumeLabel.Equals("DVD_ROM", StringComparison.OrdinalIgnoreCase))
// return RedumpSystem.MicrosoftXbox360;
// Sony PlayStation 3
if (this.FormattedVolumeLabel.Equals("PS3VOLUME", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.SonyPlayStation3;
// Sony PlayStation 4
if (this.FormattedVolumeLabel.Equals("PS4VOLUME", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.SonyPlayStation4;
// Sony PlayStation 5
if (this.FormattedVolumeLabel.Equals("PS5VOLUME", StringComparison.OrdinalIgnoreCase))
return RedumpSystem.SonyPlayStation5;
return null;
}
/// <summary>
/// Read a sector with a specified size from the drive
/// </summary>

View File

@@ -103,9 +103,8 @@ namespace MPF.Library
if (!string.IsNullOrWhiteSpace(info.SizeAndChecksums.CRC32))
info.TracksAndWriteOffsets.ClrMameProData = null;
// Add the volume label to comments, if possible
if (!string.IsNullOrWhiteSpace(drive?.VolumeLabel)
&& !drive.VolumeLabel.Equals("Audio CD", StringComparison.OrdinalIgnoreCase)
// Add the volume label to comments, if possible or necessary
if (drive.GetRedumpSystemFromVolumeLabel() == null
&& !info.CommonDiscInfo.CommentsSpecialFields.ContainsKey(SiteCode.VolumeLabel))
{
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.VolumeLabel] = drive.VolumeLabel;