diff --git a/CHANGELIST.md b/CHANGELIST.md index aca6d50d..f7994334 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -69,6 +69,7 @@ - Update Redumper PS1 output parsing - Fix previous commit, clean up helpers - Update redumper to build 173 +- Initial support for Redumper CSS outputs ### 2.5 (2023-03-12) diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs index 9307c279..91429503 100644 --- a/MPF.Modules/Redumper/Parameters.cs +++ b/MPF.Modules/Redumper/Parameters.cs @@ -1191,6 +1191,77 @@ namespace MPF.Modules.Redumper } } + /// + /// Get the DVD protection information, if possible + /// + /// Log file location + /// Formatted string representing the DVD protection, null on error + private static string GetDVDProtection(string log) + { + // If one of the files doesn't exist, we can't get info from them + if (!File.Exists(log)) + return null; + + // Setup all of the individual pieces + string region = null, rceProtection = null, copyrightProtectionSystemType = null, vobKeys = null, decryptedDiscKey = null; + using (StreamReader sr = File.OpenText(log)) + { + try + { + // Fast forward to the copyright information + while (!sr.ReadLine().Trim().StartsWith("copyright:")) ; + + // Now read until we hit the manufacturing information + string line = sr.ReadLine()?.Trim(); + while (line != null && !sr.EndOfStream) + { + if (line.StartsWith("protection system type")) + { + copyrightProtectionSystemType = line.Substring("protection system type: ".Length); + } + else if (line.StartsWith("region management information:")) + { + region = line.Substring("region management information: ".Length); + } + else if (line.StartsWith("disc key")) + { + decryptedDiscKey = line.Substring("disc key: ".Length); + } + else if (line.StartsWith("title keys")) + { + vobKeys = string.Empty; + + line = sr.ReadLine()?.Trim(); + while (!string.IsNullOrWhiteSpace(line)) + { + var match = Regex.Match(line, @"^(.*?): (.*?)$"); + if (match.Success) + vobKeys += $"{match.Groups[1].Value} Title Key: {match.Groups[2].Value}\n"; + } + } + + line = sr.ReadLine()?.Trim(); + } + } + catch { } + } + + // Now we format everything we can + string protection = string.Empty; + if (!string.IsNullOrEmpty(region)) + protection += $"Region: {region}\n"; + if (!string.IsNullOrEmpty(rceProtection)) + protection += $"RCE Protection: {rceProtection}\n"; + if (!string.IsNullOrEmpty(copyrightProtectionSystemType)) + protection += $"Copyright Protection System Type: {copyrightProtectionSystemType}\n"; + if (!string.IsNullOrEmpty(vobKeys)) + protection += vobKeys; + if (!string.IsNullOrEmpty(decryptedDiscKey)) + protection += $"Decrypted Disc Key: {decryptedDiscKey}\n"; + + return protection; + } + /// /// Get the detected error count from the input files, if possible ///