From fe8686a2bbc9eab7ded4eae67c3c12addc04e699 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 4 Oct 2024 01:41:05 -0400 Subject: [PATCH] Allow forward slashes in queries sometimes --- SabreTools.RedumpLib/Downloader.cs | 9 +++++++-- SabreTools.RedumpLib/Web/Search.cs | 16 ++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/SabreTools.RedumpLib/Downloader.cs b/SabreTools.RedumpLib/Downloader.cs index 3da2279..25a6743 100644 --- a/SabreTools.RedumpLib/Downloader.cs +++ b/SabreTools.RedumpLib/Downloader.cs @@ -51,6 +51,11 @@ namespace SabreTools.RedumpLib /// public bool OnlyList { get; set; } + /// + /// Don't replace forward slashes with `-` in queries + /// + public bool NoSlash { get; set; } + /// /// Force continuing downloads until user cancels or pages run out /// @@ -131,9 +136,9 @@ namespace SabreTools.RedumpLib break; case Feature.Quicksearch: if (OnlyList) - await Search.ListSearchResults(_client, QueryString); + await Search.ListSearchResults(_client, QueryString, NoSlash); else - await Search.DownloadSearchResults(_client, QueryString, OutDir); + await Search.DownloadSearchResults(_client, QueryString, OutDir, NoSlash); break; default: return false; diff --git a/SabreTools.RedumpLib/Web/Search.cs b/SabreTools.RedumpLib/Web/Search.cs index ed7b99c..e569137 100644 --- a/SabreTools.RedumpLib/Web/Search.cs +++ b/SabreTools.RedumpLib/Web/Search.cs @@ -15,8 +15,9 @@ namespace SabreTools.RedumpLib.Web /// /// RedumpClient for connectivity /// Query string to attempt to search for + /// Don't replace slashes with `-` in queries /// All disc IDs for the given query, null on error - public static async Task?> ListSearchResults(RedumpClient rc, string? query) + public static async Task?> ListSearchResults(RedumpClient rc, string? query, bool noSlash) { // If the query is invalid if (string.IsNullOrEmpty(query)) @@ -29,8 +30,9 @@ namespace SabreTools.RedumpLib.Web // Special characters become dashes query = query.Replace(' ', '-'); - query = query.Replace('/', '-'); - query = query.Replace('\\', '/'); + query = query.Replace('\\', '-'); + if (!noSlash) + query = query.Replace('/', '-'); // Lowercase is defined per language query = query.ToLowerInvariant(); @@ -62,7 +64,8 @@ namespace SabreTools.RedumpLib.Web /// RedumpClient for connectivity /// Query string to attempt to search for /// Output directory to save data to - public static async Task DownloadSearchResults(RedumpClient rc, string? query, string? outDir) + /// Don't replace slashes with `-` in queries + public static async Task DownloadSearchResults(RedumpClient rc, string? query, string? outDir, bool noSlash) { // If the query is invalid if (string.IsNullOrEmpty(query)) @@ -73,8 +76,9 @@ namespace SabreTools.RedumpLib.Web // Special characters become dashes query = query.Replace(' ', '-'); - query = query.Replace('/', '-'); - query = query.Replace('\\', '/'); + query = query.Replace('\\', '-'); + if (!noSlash) + query = query.Replace('/', '-'); // Lowercase is defined per language query = query.ToLowerInvariant();