", string.Empty, RegexOptions.Compiled);
-
- // Create state variables
- bool addToLast = false;
- SiteCode? lastSiteCode = null;
- string newComments = string.Empty;
-
- // Process the comments block line-by-line
- string[] commentsSeparated = oldComments.Split('\n');
- for (int i = 0; i < commentsSeparated.Length; i++)
- {
- string commentLine = commentsSeparated[i].Trim();
-
- // If we have an empty line, we want to treat this as intentional
- if (string.IsNullOrWhiteSpace(commentLine))
- {
- addToLast = false;
- lastSiteCode = null;
- newComments += $"{commentLine}\n";
- continue;
- }
-
- // Otherwise, we need to find what tag is in use
- bool foundTag = false;
- foreach (SiteCode? siteCode in Enum.GetValues(typeof(SiteCode)))
- {
- // If we have a null site code, just skip
- if (siteCode == null)
- continue;
-
- // If the line doesn't contain this tag, just skip
- var shortName = siteCode.ShortName();
- if (shortName == null || !commentLine.Contains(shortName))
- continue;
-
- // Mark as having found a tag
- foundTag = true;
-
- // Cache the current site code
- lastSiteCode = siteCode;
-
- // A subset of tags can be multiline
- addToLast = IsMultiLine(siteCode);
-
- // Skip certain site codes because of data issues
- switch (siteCode)
- {
- // Multiple
- case SiteCode.InternalSerialName:
- case SiteCode.Multisession:
- case SiteCode.VolumeLabel:
- continue;
-
- // Audio CD
- case SiteCode.RingNonZeroDataStart:
- case SiteCode.UniversalHash:
- continue;
-
- // Microsoft Xbox and Xbox 360
- case SiteCode.DMIHash:
- case SiteCode.PFIHash:
- case SiteCode.SSHash:
- case SiteCode.SSVersion:
- case SiteCode.XMID:
- case SiteCode.XeMID:
- continue;
-
- // Microsoft Xbox One and Series X/S
- case SiteCode.Filename:
- continue;
-
- // Nintendo Gamecube
- case SiteCode.InternalName:
- continue;
- }
-
- // If we don't already have this site code, add it to the dictionary
- if (!info.CommonDiscInfo.CommentsSpecialFields!.ContainsKey(siteCode.Value))
- info.CommonDiscInfo.CommentsSpecialFields[siteCode.Value] = $"(VERIFY THIS) {commentLine.Replace(shortName, string.Empty).Trim()}";
-
- // Otherwise, append the value to the existing key
- else
- info.CommonDiscInfo.CommentsSpecialFields[siteCode.Value] += $", {commentLine.Replace(shortName, string.Empty).Trim()}";
-
- break;
- }
-
- // If we didn't find a known tag, just add the line, just in case
- if (!foundTag)
- {
- if (addToLast && lastSiteCode != null)
- {
- if (!string.IsNullOrWhiteSpace(info.CommonDiscInfo.CommentsSpecialFields![lastSiteCode.Value]))
- info.CommonDiscInfo.CommentsSpecialFields[lastSiteCode.Value] += "\n";
-
- info.CommonDiscInfo.CommentsSpecialFields[lastSiteCode.Value] += commentLine;
- }
- else
- {
- newComments += $"{commentLine}\n";
- }
- }
- }
-
- // Set the new comments field
- info.CommonDiscInfo.Comments = newComments;
- }
- }
-
- // Contents
- if (includeAllData)
- {
- match = Constants.ContentsRegex.Match(discData);
- if (match.Success)
- {
- // Process the old contents block
- string oldContents = info.CommonDiscInfo.Contents
- + (string.IsNullOrEmpty(info.CommonDiscInfo.Contents) ? string.Empty : "\n")
- + WebUtility.HtmlDecode(match.Groups[1].Value)
- .Replace("\r\n", "\n")
- .Replace("
\n", "\n")
- .Replace("
", string.Empty)
- .Replace("
", string.Empty)
- .Replace("[+]", string.Empty)
- .ReplaceHtmlWithSiteCodes();
- oldContents = Regex.Replace(oldContents, @"", string.Empty, RegexOptions.Compiled);
-
- // Create state variables
- bool addToLast = false;
- SiteCode? lastSiteCode = null;
- string newContents = string.Empty;
-
- // Process the contents block line-by-line
- string[] contentsSeparated = oldContents.Split('\n');
- for (int i = 0; i < contentsSeparated.Length; i++)
- {
- string contentLine = contentsSeparated[i].Trim();
-
- // If we have an empty line, we want to treat this as intentional
- if (string.IsNullOrWhiteSpace(contentLine))
- {
- addToLast = false;
- lastSiteCode = null;
- newContents += $"{contentLine}\n";
- continue;
- }
-
- // Otherwise, we need to find what tag is in use
- bool foundTag = false;
- foreach (SiteCode? siteCode in Enum.GetValues(typeof(SiteCode)))
- {
- // If we have a null site code, just skip
- if (siteCode == null)
- continue;
-
- // If the line doesn't contain this tag, just skip
- var shortName = siteCode.ShortName();
- if (shortName == null || !contentLine.Contains(shortName))
- continue;
-
- // Cache the current site code
- lastSiteCode = siteCode;
-
- // If we don't already have this site code, add it to the dictionary
- if (!info.CommonDiscInfo.ContentsSpecialFields!.ContainsKey(siteCode.Value))
- info.CommonDiscInfo.ContentsSpecialFields[siteCode.Value] = $"(VERIFY THIS) {contentLine.Replace(shortName, string.Empty).Trim()}";
-
- // A subset of tags can be multiline
- addToLast = IsMultiLine(siteCode);
-
- // Mark as having found a tag
- foundTag = true;
- break;
- }
-
- // If we didn't find a known tag, just add the line, just in case
- if (!foundTag)
- {
- if (addToLast && lastSiteCode != null)
- {
- if (!string.IsNullOrWhiteSpace(info.CommonDiscInfo.ContentsSpecialFields![lastSiteCode.Value]))
- info.CommonDiscInfo.ContentsSpecialFields[lastSiteCode.Value] += "\n";
-
- info.CommonDiscInfo.ContentsSpecialFields[lastSiteCode.Value] += contentLine;
- }
- else
- {
- newContents += $"{contentLine}\n";
- }
- }
- }
-
- // Set the new contents field
- info.CommonDiscInfo.Contents = newContents;
- }
- }
-
- // Added
- match = Constants.AddedRegex.Match(discData);
- if (match.Success)
- {
- if (DateTime.TryParse(match.Groups[1].Value, out DateTime added))
- info.Added = added;
- else
- info.Added = null;
- }
-
- // Last Modified
- match = Constants.LastModifiedRegex.Match(discData);
- if (match.Success)
- {
- if (DateTime.TryParse(match.Groups[1].Value, out DateTime lastModified))
- info.LastModified = lastModified;
- else
- info.LastModified = null;
- }
-
- return true;
- }
-
///
/// Fill in a SubmissionInfo object from Redump, if possible
///
@@ -1173,10 +526,14 @@ namespace MPF.Core
}
#if NET40
- (bool singleFound, var foundIds) = ValidateSingleTrack(wc, info, hashData, resultProgress);
+ (bool singleFound, var foundIds, string? result) = Validator.ValidateSingleTrack(wc, info, hashData);
#else
- (bool singleFound, var foundIds) = await ValidateSingleTrack(wc, info, hashData, resultProgress);
+ (bool singleFound, var foundIds, string? result) = await Validator.ValidateSingleTrack(wc, info, hashData);
#endif
+ if (singleFound)
+ resultProgress?.Report(Result.Success(result));
+ else
+ resultProgress?.Report(Result.Failure(result));
// Ensure that all tracks are found
allFound &= singleFound;
@@ -1200,10 +557,14 @@ namespace MPF.Core
if (!info.PartiallyMatchedIDs.Any() && info.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) == true)
{
#if NET40
- (bool singleFound, var foundIds) = ValidateUniversalHash(wc, info, resultProgress);
+ (bool singleFound, var foundIds, string? result) = Validator.ValidateUniversalHash(wc, info);
#else
- (bool singleFound, var foundIds) = await ValidateUniversalHash(wc, info, resultProgress);
+ (bool singleFound, var foundIds, string? result) = await Validator.ValidateUniversalHash(wc, info);
#endif
+ if (singleFound)
+ resultProgress?.Report(Result.Success(result));
+ else
+ resultProgress?.Report(Result.Failure(result));
// Ensure that the hash is found
allFound = singleFound;
@@ -1237,18 +598,18 @@ namespace MPF.Core
{
// Skip if the track count doesn't match
#if NET40
- if (!ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))
+ if (!Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))
#else
- if (!await ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))
+ if (!await Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))
#endif
continue;
// Fill in the fields from the existing ID
resultProgress?.Report(Result.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}..."));
#if NET40
- _ = FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation);
+ _ = Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation);
#else
- _ = await FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation);
+ _ = await Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation);
#endif
resultProgress?.Report(Result.Success("Information filling complete!"));
@@ -1269,358 +630,6 @@ namespace MPF.Core
return true;
}
- // Moved to RedumpLib
- ///
- /// Inject information from a seed SubmissionInfo into the existing one
- ///
- ///
Existing submission information
- ///
User-supplied submission information
- public static void InjectSubmissionInformation(SubmissionInfo? info, SubmissionInfo? seed)
- {
- // If we have any invalid info
- if (seed == null)
- return;
-
- // Ensure that required sections exist
- info = EnsureAllSections(info);
-
- // Otherwise, inject information as necessary
- if (info.CommonDiscInfo != null && seed.CommonDiscInfo != null)
- {
- // Info that only overwrites if supplied
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Title)) info.CommonDiscInfo.Title = seed.CommonDiscInfo.Title;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.ForeignTitleNonLatin)) info.CommonDiscInfo.ForeignTitleNonLatin = seed.CommonDiscInfo.ForeignTitleNonLatin;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.DiscNumberLetter)) info.CommonDiscInfo.DiscNumberLetter = seed.CommonDiscInfo.DiscNumberLetter;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.DiscTitle)) info.CommonDiscInfo.DiscTitle = seed.CommonDiscInfo.DiscTitle;
- if (seed.CommonDiscInfo.Category != null) info.CommonDiscInfo.Category = seed.CommonDiscInfo.Category;
- if (seed.CommonDiscInfo.Region != null) info.CommonDiscInfo.Region = seed.CommonDiscInfo.Region;
- if (seed.CommonDiscInfo.Languages != null) info.CommonDiscInfo.Languages = seed.CommonDiscInfo.Languages;
- if (seed.CommonDiscInfo.LanguageSelection != null) info.CommonDiscInfo.LanguageSelection = seed.CommonDiscInfo.LanguageSelection;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Serial)) info.CommonDiscInfo.Serial = seed.CommonDiscInfo.Serial;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Barcode)) info.CommonDiscInfo.Barcode = seed.CommonDiscInfo.Barcode;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Comments)) info.CommonDiscInfo.Comments = seed.CommonDiscInfo.Comments;
- if (seed.CommonDiscInfo.CommentsSpecialFields != null) info.CommonDiscInfo.CommentsSpecialFields = seed.CommonDiscInfo.CommentsSpecialFields;
- if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Contents)) info.CommonDiscInfo.Contents = seed.CommonDiscInfo.Contents;
- if (seed.CommonDiscInfo.ContentsSpecialFields != null) info.CommonDiscInfo.ContentsSpecialFields = seed.CommonDiscInfo.ContentsSpecialFields;
-
- // Info that always overwrites
- info.CommonDiscInfo.Layer0MasteringRing = seed.CommonDiscInfo.Layer0MasteringRing;
- info.CommonDiscInfo.Layer0MasteringSID = seed.CommonDiscInfo.Layer0MasteringSID;
- info.CommonDiscInfo.Layer0ToolstampMasteringCode = seed.CommonDiscInfo.Layer0ToolstampMasteringCode;
- info.CommonDiscInfo.Layer0MouldSID = seed.CommonDiscInfo.Layer0MouldSID;
- info.CommonDiscInfo.Layer0AdditionalMould = seed.CommonDiscInfo.Layer0AdditionalMould;
-
- info.CommonDiscInfo.Layer1MasteringRing = seed.CommonDiscInfo.Layer1MasteringRing;
- info.CommonDiscInfo.Layer1MasteringSID = seed.CommonDiscInfo.Layer1MasteringSID;
- info.CommonDiscInfo.Layer1ToolstampMasteringCode = seed.CommonDiscInfo.Layer1ToolstampMasteringCode;
- info.CommonDiscInfo.Layer1MouldSID = seed.CommonDiscInfo.Layer1MouldSID;
- info.CommonDiscInfo.Layer1AdditionalMould = seed.CommonDiscInfo.Layer1AdditionalMould;
-
- info.CommonDiscInfo.Layer2MasteringRing = seed.CommonDiscInfo.Layer2MasteringRing;
- info.CommonDiscInfo.Layer2MasteringSID = seed.CommonDiscInfo.Layer2MasteringSID;
- info.CommonDiscInfo.Layer2ToolstampMasteringCode = seed.CommonDiscInfo.Layer2ToolstampMasteringCode;
-
- info.CommonDiscInfo.Layer3MasteringRing = seed.CommonDiscInfo.Layer3MasteringRing;
- info.CommonDiscInfo.Layer3MasteringSID = seed.CommonDiscInfo.Layer3MasteringSID;
- info.CommonDiscInfo.Layer3ToolstampMasteringCode = seed.CommonDiscInfo.Layer3ToolstampMasteringCode;
- }
-
- if (info.VersionAndEditions != null && seed.VersionAndEditions != null)
- {
- // Info that only overwrites if supplied
- if (!string.IsNullOrWhiteSpace(seed.VersionAndEditions.Version)) info.VersionAndEditions.Version = seed.VersionAndEditions.Version;
- if (!string.IsNullOrWhiteSpace(seed.VersionAndEditions.OtherEditions)) info.VersionAndEditions.OtherEditions = seed.VersionAndEditions.OtherEditions;
- }
-
- if (info.CopyProtection != null && seed.CopyProtection != null)
- {
- // Info that only overwrites if supplied
- if (!string.IsNullOrWhiteSpace(seed.CopyProtection.Protection)) info.CopyProtection.Protection = seed.CopyProtection.Protection;
- }
- }
-
- #endregion
-
- #region Helpers
-
- // Moved to RedumpLib
- ///
- /// Check if a site code is multi-line or not
- ///
- ///
SiteCode to check
- ///
True if the code field is multiline by default, false otherwise
- ///
TODO: This should move to Extensions at some point
- public static bool IsMultiLine(SiteCode? siteCode)
- {
- return siteCode switch
- {
- SiteCode.Extras => true,
- SiteCode.Filename => true,
- SiteCode.Games => true,
- SiteCode.GameFootage => true,
- SiteCode.Multisession => true,
- SiteCode.NetYarozeGames => true,
- SiteCode.Patches => true,
- SiteCode.PlayableDemos => true,
- SiteCode.RollingDemos => true,
- SiteCode.Savegames => true,
- SiteCode.TechDemos => true,
- SiteCode.Videos => true,
- _ => false,
- };
- }
-
- // Moved to RedumpLib
- ///
- /// Process a text block and replace with internal identifiers
- ///
- ///
Text block to process
- ///
Processed text block, if possible
- private static string ReplaceHtmlWithSiteCodes(this string text)
- {
- if (string.IsNullOrWhiteSpace(text))
- return text;
-
- foreach (SiteCode? siteCode in Enum.GetValues(typeof(SiteCode)))
- {
- var longname = siteCode.LongName();
- if (!string.IsNullOrEmpty(longname))
- text = text.Replace(longname, siteCode.ShortName());
- }
-
- // For some outdated tags, we need to use alternate names
- text = text.Replace("
Demos:", ((SiteCode?)SiteCode.PlayableDemos).ShortName());
- text = text.Replace("DMI:", ((SiteCode?)SiteCode.DMIHash).ShortName());
- text = text.Replace("
LucasArts ID:", ((SiteCode?)SiteCode.LucasArtsID).ShortName());
- text = text.Replace("PFI:", ((SiteCode?)SiteCode.PFIHash).ShortName());
- text = text.Replace("SS:", ((SiteCode?)SiteCode.SSHash).ShortName());
- text = text.Replace("SSv1:", ((SiteCode?)SiteCode.SSHash).ShortName());
- text = text.Replace("
SSv1:", ((SiteCode?)SiteCode.SSHash).ShortName());
- text = text.Replace("SSv2:", ((SiteCode?)SiteCode.SSHash).ShortName());
- text = text.Replace("
SSv2:", ((SiteCode?)SiteCode.SSHash).ShortName());
- text = text.Replace("SS version:", ((SiteCode?)SiteCode.SSVersion).ShortName());
- text = text.Replace("Universal Hash (SHA-1):", ((SiteCode?)SiteCode.UniversalHash).ShortName());
- text = text.Replace("XeMID:", ((SiteCode?)SiteCode.XeMID).ShortName());
- text = text.Replace("XMID:", ((SiteCode?)SiteCode.XMID).ShortName());
-
- return text;
- }
-
- // Moved to RedumpLib
- ///
- /// List the disc IDs associated with a given quicksearch query
- ///
- ///
RedumpWebClient for making the connection
- ///
Query string to attempt to search for
- ///
True to filter forward slashes, false otherwise
- ///
All disc IDs for the given query, null on error
-#if NET40
- private static List
? ListSearchResults(RedumpWebClient wc, string? query, bool filterForwardSlashes = true)
-#elif NETFRAMEWORK
- private async static Task?> ListSearchResults(RedumpWebClient wc, string? query, bool filterForwardSlashes = true)
-#else
- private async static Task?> ListSearchResults(RedumpHttpClient wc, string? query, bool filterForwardSlashes = true)
-#endif
- {
- // If there is an invalid query
- if (string.IsNullOrWhiteSpace(query))
- return null;
-
- var ids = new List();
-
- // Strip quotes
- query = query!.Trim('"', '\'');
-
- // Special characters become dashes
- query = query.Replace(' ', '-');
- if (filterForwardSlashes)
- query = query.Replace('/', '-');
- query = query.Replace('\\', '/');
-
- // Lowercase is defined per language
- query = query.ToLowerInvariant();
-
- // Keep getting quicksearch pages until there are none left
- try
- {
- int pageNumber = 1;
- while (true)
- {
-#if NET40
- List pageIds = wc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++));
-#elif NETFRAMEWORK
- List pageIds = await Task.Run(() => wc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++)));
-#else
- List pageIds = await wc.CheckSingleSitePage(string.Format(Constants.QuickSearchUrl, query, pageNumber++));
-#endif
- ids.AddRange(pageIds);
- if (pageIds.Count <= 1)
- break;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"An exception occurred while trying to log in: {ex}");
- return null;
- }
-
- return ids;
- }
-
- // Moved to RedumpLib
- ///
- /// Validate a single track against Redump, if possible
- ///
- /// RedumpWebClient for making the connection
- /// Existing SubmissionInfo object to fill
- /// DAT-formatted hash data to parse out
- /// Optional result progress callback
- /// True if the track was found, false otherwise; List of found values, if possible
-#if NET40
- private static (bool, List?) ValidateSingleTrack(RedumpWebClient wc, SubmissionInfo info, string hashData, IProgress? resultProgress = null)
-#elif NETFRAMEWORK
- private async static Task<(bool, List?)> ValidateSingleTrack(RedumpWebClient wc, SubmissionInfo info, string hashData, IProgress? resultProgress = null)
-#else
- private async static Task<(bool, List?)> ValidateSingleTrack(RedumpHttpClient wc, SubmissionInfo info, string hashData, IProgress? resultProgress = null)
-#endif
- {
- // If the line isn't parseable, we can't validate
- if (!InfoTool.GetISOHashValues(hashData, out long _, out var _, out var _, out var sha1))
- {
- resultProgress?.Report(Result.Failure("Line could not be parsed for hash data"));
- return (false, null);
- }
-
- // Get all matching IDs for the track
-#if NET40
- var newIds = ListSearchResults(wc, sha1);
-#else
- var newIds = await ListSearchResults(wc, sha1);
-#endif
-
- // If we got null back, there was an error
- if (newIds == null)
- {
- resultProgress?.Report(Result.Failure("There was an unknown error retrieving information from Redump"));
- return (false, null);
- }
-
- // If no IDs match any track, just return
- if (!newIds.Any())
- return (false, null);
-
- // Join the list of found IDs to the existing list, if possible
- if (info.PartiallyMatchedIDs != null && info.PartiallyMatchedIDs.Any())
- info.PartiallyMatchedIDs.AddRange(newIds);
- else
- info.PartiallyMatchedIDs = newIds;
-
- return (true, newIds);
- }
-
- // Moved to RedumpLib
- ///
- /// Validate a universal hash against Redump, if possible
- ///
- /// RedumpWebClient for making the connection
- /// Existing SubmissionInfo object to fill
- /// Optional result progress callback
- /// True if the track was found, false otherwise; List of found values, if possible
-#if NET40
- private static (bool, List?) ValidateUniversalHash(RedumpWebClient wc, SubmissionInfo info, IProgress? resultProgress = null)
-#elif NETFRAMEWORK
- private async static Task<(bool, List?)> ValidateUniversalHash(RedumpWebClient wc, SubmissionInfo info, IProgress? resultProgress = null)
-#else
- private async static Task<(bool, List?)> ValidateUniversalHash(RedumpHttpClient wc, SubmissionInfo info, IProgress? resultProgress = null)
-#endif
- {
- // If we don't have special fields
- if (info.CommonDiscInfo?.CommentsSpecialFields == null)
- {
- resultProgress?.Report(Result.Failure("Universal hash was missing"));
- return (false, null);
- }
-
- // If we don't have a universal hash
- var universalHash = info.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash];
- if (string.IsNullOrEmpty(universalHash))
- {
- resultProgress?.Report(Result.Failure("Universal hash was missing"));
- return (false, null);
- }
-
- // Format the universal hash for finding within the comments
- universalHash = $"{universalHash[..^1]}/comments/only";
-
- // Get all matching IDs for the hash
-#if NET40
- var newIds = ListSearchResults(wc, universalHash, filterForwardSlashes: false);
-#else
- var newIds = await ListSearchResults(wc, universalHash, filterForwardSlashes: false);
-#endif
-
- // If we got null back, there was an error
- if (newIds == null)
- {
- resultProgress?.Report(Result.Failure("There was an unknown error retrieving information from Redump"));
- return (false, null);
- }
-
- // If no IDs match any track, just return
- if (!newIds.Any())
- return (false, null);
-
- // Join the list of found IDs to the existing list, if possible
- if (info.PartiallyMatchedIDs != null && info.PartiallyMatchedIDs.Any())
- info.PartiallyMatchedIDs.AddRange(newIds);
- else
- info.PartiallyMatchedIDs = newIds;
-
- return (true, newIds);
- }
-
- // Moved to RedumpLib
- ///
- /// Validate that the current track count and remote track count match
- ///
- /// RedumpWebClient for making the connection
- /// Redump disc ID to retrieve
- /// Local count of tracks for the current disc
- /// True if the track count matches, false otherwise
-#if NET40
- private static bool ValidateTrackCount(RedumpWebClient wc, int id, int localCount)
-#elif NETFRAMEWORK
- private async static Task ValidateTrackCount(RedumpWebClient wc, int id, int localCount)
-#else
- private async static Task ValidateTrackCount(RedumpHttpClient wc, int id, int localCount)
-#endif
- {
- // If we can't pull the remote data, we can't match
-#if NET40
- string? discData = wc.DownloadSingleSiteID(id);
-#elif NETFRAMEWORK
- string? discData = await Task.Run(() => wc.DownloadSingleSiteID(id));
-#else
- string? discData = await wc.DownloadSingleSiteID(id);
-#endif
- if (string.IsNullOrEmpty(discData))
- return false;
-
- // Discs with only 1 track don't have a track count listed
- var match = Constants.TrackCountRegex.Match(discData);
- if (!match.Success && localCount == 1)
- return true;
- else if (!match.Success)
- return false;
-
- // If the count isn't parseable, we're not taking chances
- if (!Int32.TryParse(match.Groups[1].Value, out int remoteCount))
- return false;
-
- // Finally check to see if the counts match
- return localCount == remoteCount;
- }
-
#endregion
}
}
diff --git a/MPF.Core/Utilities/EnumExtensions.cs b/MPF.Core/Utilities/EnumExtensions.cs
index 6c45e530..d44acfb2 100644
--- a/MPF.Core/Utilities/EnumExtensions.cs
+++ b/MPF.Core/Utilities/EnumExtensions.cs
@@ -8,34 +8,6 @@ namespace MPF.Core.Utilities
{
public static class EnumExtensions
{
- // Moved to RedumpLib
- ///
- /// Determine if a system is okay if it's not detected by Windows
- ///
- /// RedumpSystem value to check
- /// True if Windows show see a disc when dumping, false otherwise
- public static bool DetectedByWindows(this RedumpSystem? system)
- {
- return system switch
- {
- RedumpSystem.AmericanLaserGames3DO
- or RedumpSystem.AppleMacintosh
- or RedumpSystem.Atari3DO
- or RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem
- or RedumpSystem.NewJatreCDi
- or RedumpSystem.NintendoGameCube
- or RedumpSystem.NintendoWii
- or RedumpSystem.NintendoWiiU
- or RedumpSystem.PhilipsCDi
- or RedumpSystem.PhilipsCDiDigitalVideo
- or RedumpSystem.Panasonic3DOInteractiveMultiplayer
- or RedumpSystem.PanasonicM2
- or RedumpSystem.PioneerLaserActive
- or RedumpSystem.SuperAudioCD => false,
- _ => true,
- };
- }
-
///
/// Determine if the media supports drive speeds
///
@@ -56,72 +28,6 @@ namespace MPF.Core.Utilities
};
}
- // Moved to RedumpLib
- ///
- /// Determine if a system has reversed ringcodes
- ///
- /// RedumpSystem value to check
- /// True if the system has reversed ringcodes, false otherwise
- public static bool HasReversedRingcodes(this RedumpSystem? system)
- {
- return system switch
- {
- RedumpSystem.SonyPlayStation2
- or RedumpSystem.SonyPlayStation3
- or RedumpSystem.SonyPlayStation4
- or RedumpSystem.SonyPlayStation5
- or RedumpSystem.SonyPlayStationPortable => true,
- _ => false,
- };
- }
-
- // Moved to RedumpLib
- ///
- /// Determine if a system is considered audio-only
- ///
- /// RedumpSystem value to check
- /// True if the system is audio-only, false otherwise
- ///
- /// Philips CD-i should NOT be in this list. It's being included until there's a
- /// reasonable distinction between CD-i and CD-i ready on the database side.
- ///
- public static bool IsAudio(this RedumpSystem? system)
- {
- return system switch
- {
- RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem
- or RedumpSystem.AudioCD
- or RedumpSystem.DVDAudio
- or RedumpSystem.HasbroiONEducationalGamingSystem
- or RedumpSystem.HasbroVideoNow
- or RedumpSystem.HasbroVideoNowColor
- or RedumpSystem.HasbroVideoNowJr
- or RedumpSystem.HasbroVideoNowXP
- or RedumpSystem.PhilipsCDi
- or RedumpSystem.PlayStationGameSharkUpdates
- or RedumpSystem.SuperAudioCD => true,
- _ => false,
- };
- }
-
- // Moved to RedumpLib
- ///
- /// Determine if a system is considered XGD
- ///
- /// RedumpSystem value to check
- /// True if the system is XGD, false otherwise
- public static bool IsXGD(this RedumpSystem? system)
- {
- return system switch
- {
- RedumpSystem.MicrosoftXbox
- or RedumpSystem.MicrosoftXbox360
- or RedumpSystem.MicrosoftXboxOne
- or RedumpSystem.MicrosoftXboxSeriesXS => true,
- _ => false,
- };
- }
-
///
/// List all programs with their short usable names
///
diff --git a/MPF.Core/Utilities/OptionsLoader.cs b/MPF.Core/Utilities/OptionsLoader.cs
index 6adb6646..b61f8750 100644
--- a/MPF.Core/Utilities/OptionsLoader.cs
+++ b/MPF.Core/Utilities/OptionsLoader.cs
@@ -4,6 +4,7 @@ using System.IO;
using MPF.Core.Converters;
using MPF.Core.Data;
using Newtonsoft.Json;
+using SabreTools.RedumpLib;
using SabreTools.RedumpLib.Data;
namespace MPF.Core.Utilities
@@ -177,12 +178,12 @@ namespace MPF.Core.Utilities
else if (args[startIndex].StartsWith("-l=") || args[startIndex].StartsWith("--load-seed="))
{
string seedInfo = args[startIndex].Split('=')[1];
- info = SubmissionInfoTool.CreateFromFile(seedInfo);
+ info = Builder.CreateFromFile(seedInfo);
}
else if (args[startIndex] == "-l" || args[startIndex] == "--load-seed")
{
string seedInfo = args[startIndex + 1];
- info = SubmissionInfoTool.CreateFromFile(seedInfo);
+ info = Builder.CreateFromFile(seedInfo);
startIndex++;
}
diff --git a/MPF.Test/Library/InfoToolTests.cs b/MPF.Test/Library/InfoToolTests.cs
index 0bff1a93..12619ed5 100644
--- a/MPF.Test/Library/InfoToolTests.cs
+++ b/MPF.Test/Library/InfoToolTests.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using MPF.Core;
+using SabreTools.RedumpLib;
using SabreTools.RedumpLib.Data;
using Xunit;
@@ -8,47 +9,6 @@ namespace MPF.Test.Library
{
public class InfoToolTests
{
- [Theory]
- [InlineData(null, 0, 0, 0, 0, null)]
- [InlineData(null, 12345, 0, 0, 0, null)]
- [InlineData(null, 12345, 1, 0, 0, null)]
- [InlineData(null, 12345, 1, 2, 0, null)]
- [InlineData(null, 12345, 1, 2, 3, null)]
- [InlineData(MediaType.CDROM, 0, 0, 0, 0, "CD-ROM")]
- [InlineData(MediaType.CDROM, 12345, 0, 0, 0, "CD-ROM")]
- [InlineData(MediaType.CDROM, 12345, 1, 0, 0, "CD-ROM")]
- [InlineData(MediaType.CDROM, 12345, 1, 2, 0, "CD-ROM")]
- [InlineData(MediaType.CDROM, 12345, 1, 2, 3, "CD-ROM")]
- [InlineData(MediaType.DVD, 0, 0, 0, 0, "DVD-ROM-5")]
- [InlineData(MediaType.DVD, 12345, 0, 0, 0, "DVD-ROM-5")]
- [InlineData(MediaType.DVD, 12345, 1, 0, 0, "DVD-ROM-9")]
- [InlineData(MediaType.DVD, 12345, 1, 2, 0, "DVD-ROM-9")]
- [InlineData(MediaType.DVD, 12345, 1, 2, 3, "DVD-ROM-9")]
- [InlineData(MediaType.BluRay, 0, 0, 0, 0, "BD-ROM-25")]
- [InlineData(MediaType.BluRay, 12345, 0, 0, 0, "BD-ROM-25")]
- [InlineData(MediaType.BluRay, 26_843_531_857, 0, 0, 0, "BD-ROM-33")]
- [InlineData(MediaType.BluRay, 12345, 1, 0, 0, "BD-ROM-50")]
- [InlineData(MediaType.BluRay, 53_687_063_713, 1, 0, 0, "BD-ROM-66")]
- [InlineData(MediaType.BluRay, 12345, 1, 2, 0, "BD-ROM-100")]
- [InlineData(MediaType.BluRay, 12345, 1, 2, 3, "BD-ROM-128")]
- [InlineData(MediaType.UMD, 0, 0, 0, 0, "UMD-SL")]
- [InlineData(MediaType.UMD, 12345, 0, 0, 0, "UMD-SL")]
- [InlineData(MediaType.UMD, 12345, 1, 0, 0, "UMD-DL")]
- [InlineData(MediaType.UMD, 12345, 1, 2, 0, "UMD-DL")]
- [InlineData(MediaType.UMD, 12345, 1, 2, 3, "UMD-DL")]
- public void GetFixedMediaTypeTest(
- MediaType? mediaType,
- long size,
- long layerbreak,
- long layerbreak2,
- long layerbreak3,
- string? expected)
- {
- // TODO: Add tests around BDU
- var actual = InfoTool.GetFixedMediaType(mediaType, null, size, layerbreak, layerbreak2, layerbreak3);
- Assert.Equal(expected, actual);
- }
-
[Theory]
[InlineData(null, "")]
[InlineData(" ", "")]
@@ -90,7 +50,7 @@ namespace MPF.Test.Library
};
// Process the special fields
- InfoTool.ProcessSpecialFields(info);
+ Formatter.ProcessSpecialFields(info);
// Validate the basics
Assert.NotNull(info.CommonDiscInfo.Comments);
@@ -117,7 +77,7 @@ namespace MPF.Test.Library
};
// Process the special fields
- InfoTool.ProcessSpecialFields(info);
+ Formatter.ProcessSpecialFields(info);
// Validate
Assert.Null(info.CommonDiscInfo);
@@ -146,7 +106,7 @@ namespace MPF.Test.Library
};
// Process the special fields
- InfoTool.ProcessSpecialFields(info);
+ Formatter.ProcessSpecialFields(info);
// Validate the basics
Assert.NotNull(info.CommonDiscInfo.Comments);
@@ -180,7 +140,7 @@ namespace MPF.Test.Library
};
// Process the special fields
- InfoTool.ProcessSpecialFields(info);
+ Formatter.ProcessSpecialFields(info);
// Validate the basics
Assert.NotNull(info.CommonDiscInfo.Comments);
diff --git a/MPF.Test/MPF.Test.csproj b/MPF.Test/MPF.Test.csproj
index adef720d..9853ba6b 100644
--- a/MPF.Test/MPF.Test.csproj
+++ b/MPF.Test/MPF.Test.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/MPF.UI.Core/MPF.UI.Core.csproj b/MPF.UI.Core/MPF.UI.Core.csproj
index 03367096..61ee1e7d 100644
--- a/MPF.UI.Core/MPF.UI.Core.csproj
+++ b/MPF.UI.Core/MPF.UI.Core.csproj
@@ -32,7 +32,7 @@
-
+
diff --git a/MPF.UI.Core/Windows/MainWindow.xaml.cs b/MPF.UI.Core/Windows/MainWindow.xaml.cs
index a531f680..3a9cd322 100644
--- a/MPF.UI.Core/Windows/MainWindow.xaml.cs
+++ b/MPF.UI.Core/Windows/MainWindow.xaml.cs
@@ -4,6 +4,7 @@ using System.Windows;
using System.Windows.Controls;
using MPF.Core;
using MPF.Core.UI.ViewModels;
+using SabreTools.RedumpLib;
using SabreTools.RedumpLib.Data;
using WPFCustomMessageBox;
using WinForms = System.Windows.Forms;
@@ -197,7 +198,7 @@ namespace MPF.UI.Core.Windows
{
var submissionInfo = MainViewModel.CreateDebugSubmissionInfo();
var result = ShowDiscInformationWindow(submissionInfo);
- InfoTool.ProcessSpecialFields(result.Item2);
+ Formatter.ProcessSpecialFields(result.Item2);
}
///
diff --git a/MPF/MPF.csproj b/MPF/MPF.csproj
index 08ec6606..0c1554a5 100644
--- a/MPF/MPF.csproj
+++ b/MPF/MPF.csproj
@@ -45,7 +45,7 @@
runtime; compile; build; native; analyzers; buildtransitive
-
+