diff --git a/RedumpTool/Features/QueryFeature.cs b/RedumpTool/Features/QueryFeature.cs index dbaac3c..3b83f7e 100644 --- a/RedumpTool/Features/QueryFeature.cs +++ b/RedumpTool/Features/QueryFeature.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using SabreTools.CommandLine.Inputs; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpOrg; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace RedumpTool.Features { diff --git a/RedumpTool/Features/SiteFeature.cs b/RedumpTool/Features/SiteFeature.cs index 99d85b0..cb3b456 100644 --- a/RedumpTool/Features/SiteFeature.cs +++ b/RedumpTool/Features/SiteFeature.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using SabreTools.CommandLine.Inputs; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpOrg; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace RedumpTool.Features { diff --git a/RedumpTool/Features/UserFeature.cs b/RedumpTool/Features/UserFeature.cs index e6c22cd..dce2ebf 100644 --- a/RedumpTool/Features/UserFeature.cs +++ b/RedumpTool/Features/UserFeature.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using SabreTools.CommandLine.Inputs; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpOrg; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace RedumpTool.Features { diff --git a/SabreTools.RedumpLib.Test/ValidatorTests.cs b/SabreTools.RedumpLib.Test/ValidatorTests.cs index d6d1933..dc14afd 100644 --- a/SabreTools.RedumpLib.Test/ValidatorTests.cs +++ b/SabreTools.RedumpLib.Test/ValidatorTests.cs @@ -1,6 +1,5 @@ using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Data.Sections; -using SabreTools.RedumpLib.RedumpOrg.Data; using Xunit; namespace SabreTools.RedumpLib.Test diff --git a/SabreTools.RedumpLib/Builder.cs b/SabreTools.RedumpLib/Builder.cs index dc7398d..abb532e 100644 --- a/SabreTools.RedumpLib/Builder.cs +++ b/SabreTools.RedumpLib/Builder.cs @@ -12,7 +12,6 @@ using Newtonsoft.Json; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Data.Sections; using SabreTools.RedumpLib.RedumpOrg; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace SabreTools.RedumpLib { diff --git a/SabreTools.RedumpLib/RedumpInfo/Client.cs b/SabreTools.RedumpLib/RedumpInfo/Client.cs index de70481..f617a80 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Client.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Client.cs @@ -90,16 +90,6 @@ namespace SabreTools.RedumpLib.RedumpInfo #region Constants - /// - /// Regex matching the current creation time for login - /// - public static readonly Regex LoginCreationTimeRegex = new(@"", RegexOptions.Compiled); - - /// - /// Regex matching the current nonce token for login - /// - public static readonly Regex LoginTokenRegex = new(@"", RegexOptions.Compiled); - /// /// Login page URL /// @@ -186,8 +176,8 @@ namespace SabreTools.RedumpLib.RedumpInfo // Get the current token from the login page var loginPage = await DownloadString(LoginUrl); - string creationTime = LoginCreationTimeRegex.Match(loginPage ?? string.Empty).Groups[1].Value; - string token = LoginTokenRegex.Match(loginPage ?? string.Empty).Groups[1].Value; + string creationTime = Constants.LoginCreationTimeRegex.Match(loginPage ?? string.Empty).Groups[1].Value; + string token = Constants.LoginTokenRegex.Match(loginPage ?? string.Empty).Groups[1].Value; #if NETCOREAPP // Construct the login request @@ -459,7 +449,7 @@ namespace SabreTools.RedumpLib.RedumpInfo if (dumpsPage.Contains("Download:")) { if (Debug) Console.WriteLine($"DEBUG: CheckSingleSitePage(\"{url}\") - Single disc page"); - var value = RedumpOrg.Data.Constants.SfvRegex.Match(dumpsPage).Groups[1].Value; + var value = Constants.SfvRegex.Match(dumpsPage).Groups[1].Value; if (int.TryParse(value, out int id)) ids.Add(id); @@ -467,7 +457,7 @@ namespace SabreTools.RedumpLib.RedumpInfo } // Otherwise, traverse each dump on the page - var matches = RedumpOrg.Data.Constants.DiscRegex.Matches(dumpsPage); + var matches = Constants.DiscRegex.Matches(dumpsPage); foreach (Match? match in matches) { if (match is null) @@ -594,7 +584,7 @@ namespace SabreTools.RedumpLib.RedumpInfo } // Otherwise, traverse each dump on the page - var matches = RedumpOrg.Data.Constants.NewDiscRegex.Matches(dumpsPage); + var matches = Constants.NewDiscRegex.Matches(dumpsPage); foreach (Match? match in matches) { if (match is null) @@ -958,8 +948,8 @@ namespace SabreTools.RedumpLib.RedumpInfo var oldDiscPage = File.ReadAllText(Path.Combine(paddedIdDir, "disc.html")); // Check for the last modified date in both pages - var oldResult = RedumpOrg.Data.Constants.LastModifiedRegex.Match(oldDiscPage); - var newResult = RedumpOrg.Data.Constants.LastModifiedRegex.Match(discPage); + var oldResult = Constants.LastModifiedRegex.Match(oldDiscPage); + var newResult = Constants.LastModifiedRegex.Match(discPage); // If both pages contain the same modified date, skip it if (oldResult.Success && newResult.Success && oldResult.Groups[1].Value == newResult.Groups[1].Value) @@ -977,8 +967,8 @@ namespace SabreTools.RedumpLib.RedumpInfo } // If the downloaded data is invalid or otherwise empty, skip it - var hasAddedDate = RedumpOrg.Data.Constants.AddedRegex.Match(discPage); - var hasModifiedDate = RedumpOrg.Data.Constants.LastModifiedRegex.Match(discPage); + var hasAddedDate = Constants.AddedRegex.Match(discPage); + var hasModifiedDate = Constants.LastModifiedRegex.Match(discPage); if (!hasAddedDate.Success && !hasModifiedDate.Success) { Console.WriteLine($"ID {paddedId} retieved an empty page, skipping..."); @@ -1164,8 +1154,8 @@ namespace SabreTools.RedumpLib.RedumpInfo var oldDiscPage = File.ReadAllText(Path.Combine(paddedIdDir, "disc.html")); // Check for the full match ID in both pages - var oldResult = RedumpOrg.Data.Constants.FullMatchRegex.Match(oldDiscPage); - var newResult = RedumpOrg.Data.Constants.FullMatchRegex.Match(discPage); + var oldResult = Constants.FullMatchRegex.Match(oldDiscPage); + var newResult = Constants.FullMatchRegex.Match(discPage); // If both pages contain the same ID, skip it if (oldResult.Success && newResult.Success && oldResult.Groups[1].Value == newResult.Groups[1].Value) @@ -1182,8 +1172,8 @@ namespace SabreTools.RedumpLib.RedumpInfo } // Check the added date as a backup - oldResult = RedumpOrg.Data.Constants.AddedRegex.Match(oldDiscPage); - newResult = RedumpOrg.Data.Constants.AddedRegex.Match(discPage); + oldResult = Constants.AddedRegex.Match(oldDiscPage); + newResult = Constants.AddedRegex.Match(discPage); // If the downloaded data is invalid or otherwise empty, skip it if (oldResult.Success && !newResult.Success) diff --git a/SabreTools.RedumpLib/RedumpInfo/Constants.cs b/SabreTools.RedumpLib/RedumpInfo/Constants.cs new file mode 100644 index 0000000..09b9319 --- /dev/null +++ b/SabreTools.RedumpLib/RedumpInfo/Constants.cs @@ -0,0 +1,217 @@ +using System.Text.RegularExpressions; +using SabreTools.RedumpLib.Data; + +namespace SabreTools.RedumpLib.RedumpInfo +{ + public static class Constants + { + #region Regular Expressions + + /// + /// Regex matching the added field on a disc page + /// + public static readonly Regex AddedRegex = new(@"Added(.*?)", RegexOptions.Compiled); + + /// + /// Regex matching the barcodes field on a disc page + /// + public static readonly Regex BarcodesRegex = new(@"Barcodes(.*?)", RegexOptions.Compiled); + + /// + /// Regex matching the BCA field on a disc page + /// + public static readonly Regex BcaRegex = new(@"

BCA

" + + @"
" + + @"" + + "" + + "" + + "" + + "" + + "" + + "", RegexOptions.Compiled | RegexOptions.Singleline); + + /// + /// Regex matching the category field on a disc page + /// + public static readonly Regex CategoryRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the comments field on a disc page + /// + public static readonly Regex CommentsRegex = new(@"

Comments

(.*?)

", RegexOptions.Compiled | RegexOptions.Singleline); + + /// + /// Regex matching the contents field on a disc page + /// + public static readonly Regex ContentsRegex = new(@"

Contents

(.*?)

", RegexOptions.Compiled | RegexOptions.Singleline); + + /// + /// Regex matching individual disc links on a results page + /// + public static readonly Regex DiscRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the disc number or letter field on a disc page + /// + public static readonly Regex DiscNumberLetterRegex = new(@"\((.*?)\)", RegexOptions.Compiled); + + /// + /// Regex matching the dumpers on a disc page + /// + public static readonly Regex DumpersRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the edition field on a disc page + /// + public static readonly Regex EditionRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the error count field on a disc page + /// + public static readonly Regex ErrorCountRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the foreign title field on a disc page + /// + public static readonly Regex ForeignTitleRegex = new(@"

(.*?)

", RegexOptions.Compiled); + + /// + /// Regex matching the "full match" ID list from a WIP disc page + /// + /// TODO: Determine if this has a parallel in redump.info + public static readonly Regex FullMatchRegex = new(@"
", RegexOptions.Compiled); + + /// + /// Regex matching the languages field on a disc page + /// + public static readonly Regex LanguagesRegex = new(@"\s*", RegexOptions.Compiled); + + /// + /// Regex matching the last modified field on a disc page + /// + public static readonly Regex LastModifiedRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the current creation time for login + /// + public static readonly Regex LoginCreationTimeRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the current nonce token for login + /// + public static readonly Regex LoginTokenRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the media field on a disc page + /// + public static readonly Regex MediaRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching individual WIP disc links on a results page + /// + /// TODO: Determine if this has a parallel in redump.info, maybe the queue page? + public static readonly Regex NewDiscRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the "partial match" ID list from a WIP disc page + /// + /// TODO: Determine if this has a parallel in redump.info + public static readonly Regex PartialMatchRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the disc key on a PS3 disc page + /// + public static readonly Regex PS3DiscKey = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the PVD field on a disc page + /// + public static readonly Regex PvdRegex = new("

PVD

" + + @"
" + + @"
RowContentsASCII
(?.*?)(?.*?)(?.*?)
(?.*?)(?.*?)(?.*?)
(?.*?)(?.*?)(?.*?)
(?.*?)(?.*?)(?.*?)
Category(.*?)
Edition(.*?)
Errors(.*?)
full match ids: (.*?)
Modified(.*?)
Media(.*?)
partial match ids: (.*?)
Disc Key(.*?)
" + + "" + + "" + + "" + + "" + + "" + + "", RegexOptions.Compiled | RegexOptions.Singleline); + + /// + /// Regex matching the region field on a disc page + /// + public static readonly Regex RegionRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the SFV link on a disc page + /// + /// TODO: Determine if this has a parallel in redump.info + public static readonly Regex SfvRegex = new(@"/disc/(\d+)/sfv/", RegexOptions.Compiled); + + /// + /// Regex matching the system field on a disc page + /// + public static readonly Regex SystemRegex = new(@"", RegexOptions.Compiled | RegexOptions.Singleline); + + /// + /// Regex matching the track count on a disc page + /// + /// TODO: There doesn't seem to be a track count anymore + public static readonly Regex TrackCountRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the version field on a disc page + /// + public static readonly Regex VersionRegex = new(@"", RegexOptions.Compiled); + + /// + /// Regex matching the write offset field on a disc page + /// + /// TODO: There doesn't seem to be a write offset anymore + public static readonly Regex WriteOffsetRegex = new(@"", RegexOptions.Compiled); + + #endregion + + #region Subpath Sets + + /// + /// All disc page subpaths as a set + /// + public static readonly DiscSubpath[] AllDiscSubpaths = + [ + DiscSubpath.Cuesheet, + DiscSubpath.Edit, + DiscSubpath.History, + ]; + + #endregion + } +} diff --git a/SabreTools.RedumpLib/RedumpOrg/Client.cs b/SabreTools.RedumpLib/RedumpOrg/Client.cs index 00df43d..c09b0fd 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Client.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Client.cs @@ -10,7 +10,6 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using SabreTools.RedumpLib.Data; -using SabreTools.RedumpLib.RedumpOrg.Data; using SabreTools.RedumpLib.Web; namespace SabreTools.RedumpLib.RedumpOrg diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Constants.cs b/SabreTools.RedumpLib/RedumpOrg/Constants.cs similarity index 99% rename from SabreTools.RedumpLib/RedumpOrg/Data/Constants.cs rename to SabreTools.RedumpLib/RedumpOrg/Constants.cs index e040991..7802bb9 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Constants.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Constants.cs @@ -1,7 +1,7 @@ using System.Text.RegularExpressions; using SabreTools.RedumpLib.Data; -namespace SabreTools.RedumpLib.RedumpOrg.Data +namespace SabreTools.RedumpLib.RedumpOrg { public static class Constants { diff --git a/SabreTools.RedumpLib/RedumpOrg/UrlBuilder.cs b/SabreTools.RedumpLib/RedumpOrg/UrlBuilder.cs index 4c976eb..2d137b2 100644 --- a/SabreTools.RedumpLib/RedumpOrg/UrlBuilder.cs +++ b/SabreTools.RedumpLib/RedumpOrg/UrlBuilder.cs @@ -1,7 +1,6 @@ using System; using System.Text; using SabreTools.RedumpLib.Data; -using SabreTools.RedumpLib.RedumpOrg.Data; // TODO: Errors should validate number or number range (# or #-#)
ContentsDateTimeGMT
Creation(?.*?)(?.*?)(?.*?)(?.*?)
Modification(?.*?)(?.*?)(?.*?)(?.*?)
Expiration(?.*?)(?.*?)(?.*?)(?.*?)
Effective(?.*?)(?.*?)(?.*?)(?.*?)
Region" + + @"", RegexOptions.Compiled); + + /// + /// Regex matching a double-layer disc ringcode information + /// + /// TODO: Determine if this has a parallel in redump.info, maybe the queue page? + public static readonly Regex RingCodeDoubleRegex = new(@"", RegexOptions.Compiled | RegexOptions.Singleline); // Varies based on available fields, like Addtional Mould + + /// + /// Regex matching a single-layer disc ringcode information + /// + /// TODO: Determine if this has a parallel in redump.info, maybe the queue page? + public static readonly Regex RingCodeSingleRegex = new(@"", RegexOptions.Compiled | RegexOptions.Singleline); // Varies based on available fields, like Addtional Mould + + /// + /// Regex matching the serial field on a disc page + /// + public static readonly Regex SerialRegex = new(@"<
Disc Serial(.*?)
System", RegexOptions.Compiled); + + /// + /// Regex matching the title field on a disc page + /// + public static readonly Regex TitleRegex = new(@"

(.*?)

", RegexOptions.Compiled); + + /// + /// Regex matching a single track on a disc page + /// + /// TODO: Figure out how to translate the new page to this + public static readonly Regex TrackRegex = new(@"
(?.*?)(?.*?)(?.*?)(?.*?)(?.*?)(?.*?)(?.*?)(?.*?)(?.*?)
Number of tracks(.*?)
Version(.*?)
Write offset(.*?)