diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index 675bf83..05e447a 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -35,6 +35,78 @@ namespace SabreTools.RedumpLib.Data return -1; } + /// + /// Adjust the disc type based on size and layerbreak information + /// + /// Existing SubmissionInfo object to fill + /// Corrected disc type, if possible + public static void NormalizeDiscType(this SubmissionInfo info) + { + // If we have nothing valid, do nothing + if (info.DiscIdentity.Media is null) + return; + +#pragma warning disable IDE0010 + switch (info.DiscIdentity.Media) + { + case MediaType.DVD5: + case MediaType.DVD9: + if (info.DiscIdentifiers.Layerbreak != default) + info.DiscIdentity.Media = MediaType.DVD9; + else + info.DiscIdentity.Media = MediaType.DVD5; + break; + + case MediaType.BD25: + case MediaType.BD33: + case MediaType.BD50: + case MediaType.BD66: + case MediaType.BD100: + case MediaType.BD128: + // Extract the size from the hashes + long size = ExtractSizeFromHashData(info.DumpMetadata.Dat); + + if (info.DiscIdentifiers.Layerbreak3 != default) + info.DiscIdentity.Media = MediaType.BD128; + else if (info.DiscIdentifiers.Layerbreak2 != default) + info.DiscIdentity.Media = MediaType.BD100; + else if (info.DiscIdentifiers.Layerbreak != default && info.DumpMetadata.PICIdentifier == "BDU") + info.DiscIdentity.Media = MediaType.BD66; + else if (info.DiscIdentifiers.Layerbreak != default && size > 50_050_629_632) + info.DiscIdentity.Media = MediaType.BD66; + else if (info.DiscIdentifiers.Layerbreak != default) + info.DiscIdentity.Media = MediaType.BD50; + else if (info.DumpMetadata.PICIdentifier == "BDU") + info.DiscIdentity.Media = MediaType.BD33; + else if (size > 25_025_314_816) + info.DiscIdentity.Media = MediaType.BD33; + else + info.DiscIdentity.Media = MediaType.BD25; + break; + + case MediaType.HDDVDSL: + case MediaType.HDDVDDL: + if (info.DiscIdentifiers.Layerbreak != default) + info.DiscIdentity.Media = MediaType.HDDVDDL; + else + info.DiscIdentity.Media = MediaType.HDDVDSL; + break; + + case MediaType.UMDSL: + case MediaType.UMDDL: + if (info.DiscIdentifiers.Layerbreak != default) + info.DiscIdentity.Media = MediaType.UMDDL; + else + info.DiscIdentity.Media = MediaType.UMDSL; + break; + + // All other disc types are not processed + default: + break; + } +#pragma warning restore IDE0010 + } + /// /// Adjust the disc type based on size and layerbreak information /// @@ -106,7 +178,8 @@ namespace SabreTools.RedumpLib.Data } #pragma warning restore IDE0010 } - #endregion + + #endregion #region Cross-Enumeration diff --git a/SabreTools.RedumpLib/Data/Sections/DumpMetadataSection.cs b/SabreTools.RedumpLib/Data/Sections/DumpMetadataSection.cs index 3f43347..21fc806 100644 --- a/SabreTools.RedumpLib/Data/Sections/DumpMetadataSection.cs +++ b/SabreTools.RedumpLib/Data/Sections/DumpMetadataSection.cs @@ -27,10 +27,13 @@ namespace SabreTools.RedumpLib.Data.Sections [JsonIgnore] public Dictionary ContentsSpecialFields { get; set; } = []; - // TODO: Add back Dictionary?> FullProtections [JsonProperty(PropertyName = "protection", NullValueHandling = NullValueHandling.Ignore)] public string? Protection { get; set; } + /// This is a non-standard field + [JsonIgnore] + public Dictionary?>? FullProtections { get; set; } + [JsonProperty(PropertyName = "sector_ranges", NullValueHandling = NullValueHandling.Ignore)] public string? SectorRanges { get; set; } @@ -49,6 +52,10 @@ namespace SabreTools.RedumpLib.Data.Sections [JsonProperty(PropertyName = "pic", NullValueHandling = NullValueHandling.Ignore)] public string? PIC { get; set; } + /// This is a non-standard field + [JsonProperty(PropertyName = "pic_identifier", NullValueHandling = NullValueHandling.Ignore)] + public string? PICIdentifier { get; set; } + [JsonProperty(PropertyName = "cue", NullValueHandling = NullValueHandling.Ignore)] public string? Cuesheet { get; set; } diff --git a/SabreTools.RedumpLib/Tools/Validator.cs b/SabreTools.RedumpLib/Tools/Validator.cs index 65e1698..1da66fd 100644 --- a/SabreTools.RedumpLib/Tools/Validator.cs +++ b/SabreTools.RedumpLib/Tools/Validator.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Web; -using SubmissionInfo = SabreTools.RedumpLib.RedumpOrg.SubmissionInfo; namespace SabreTools.RedumpLib.Tools { @@ -46,11 +45,11 @@ namespace SabreTools.RedumpLib.Tools public static async Task?> ValidateUniversalHash(Client client, SubmissionInfo info) { // If we don't have special fields - if (info.CommonDiscInfo.CommentsSpecialFields is null) + if (info.DumpMetadata.CommentsSpecialFields is null) return null; // If we don't have a universal hash - string? universalHash = info.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash]; + string? universalHash = info.DiscIdentifiers.UniversalHash; if (string.IsNullOrEmpty(universalHash)) return null;