Skip to content

Commit 06e7ae1

Browse files
committed
Add set download library methods
1 parent 02efdd4 commit 06e7ae1

2 files changed

Lines changed: 60 additions & 3 deletions

File tree

SabreTools.RedumpLib/Web/Discs.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,35 @@ public static async Task<List<int>> DownloadLastModified(this RedumpClient clien
147147
return ids;
148148
}
149149

150+
/// <summary>
151+
/// Download the specified set of site disc pages
152+
/// </summary>
153+
/// <param name="client">RedumpClient for connectivity</param>
154+
/// <param name="siteIds">Set of site IDs to download</param>
155+
/// <param name="outDir">Output directory to save data to</param>
156+
/// <param name="forceDownload">True to force all downloads, false otherwise</param>
157+
/// <param name="forceContinue">Force continuation of download</param>
158+
/// <returns>All disc IDs that successfully downloaded, empty on error</returns>
159+
public static async Task<List<int>> DownloadSiteSet(this RedumpClient client,
160+
List<int> siteIds,
161+
string? outDir,
162+
bool forceDownload,
163+
bool forceContinue)
164+
{
165+
List<int> ids = [];
166+
foreach (int id in siteIds)
167+
{
168+
bool downloaded = await client.DownloadSingleSiteID(id, outDir, rename: true, forceDownload, forceContinue);
169+
if (downloaded)
170+
{
171+
ids.Add(id);
172+
DelayHelper.DelayRandom();
173+
}
174+
}
175+
176+
return ids;
177+
}
178+
150179
/// <summary>
151180
/// Download the specified range of site disc pages
152181
/// </summary>
@@ -156,7 +185,7 @@ public static async Task<List<int>> DownloadLastModified(this RedumpClient clien
156185
/// <param name="forceContinue">Force continuation of download</param>
157186
/// <param name="minId">Starting ID for the range</param>
158187
/// <param name="maxId">Ending ID for the range (inclusive)</param>
159-
/// <returns>All disc IDs in last modified range, empty on error</returns>
188+
/// <returns>All disc IDs that successfully downloaded, empty on error</returns>
160189
public static async Task<List<int>> DownloadSiteRange(this RedumpClient client,
161190
string? outDir,
162191
bool forceDownload,

SabreTools.RedumpLib/Web/WIP.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ public static async Task<List<int>> DownloadLastSubmitted(this RedumpClient clie
2222
return await client.CheckSingleWIPPage(Constants.WipDumpsUrl, outDir, forceDownload, forceContinue) ?? [];
2323
}
2424

25+
/// <summary>
26+
/// Download the specified range of WIP disc pages
27+
/// </summary>
28+
/// <param name="client">RedumpClient for connectivity</param>
29+
/// <param name="wipIds">Set of WIP IDs to download</param>
30+
/// <param name="outDir">Output directory to save data to</param>
31+
/// <param name="forceDownload">True to force all downloads, false otherwise</param>
32+
/// <returns>All WIP IDs in last submitted range, empty on error</returns>
33+
public static async Task<List<int>> DownloadWIPSet(this RedumpClient client, List<int> wipIds, string? outDir, bool forceDownload)
34+
{
35+
List<int> ids = [];
36+
foreach (int id in wipIds)
37+
{
38+
bool downloaded = await client.DownloadSingleWIPID(id, outDir, rename: true, forceDownload);
39+
if (downloaded)
40+
{
41+
ids.Add(id);
42+
DelayHelper.DelayRandom();
43+
}
44+
}
45+
46+
return ids;
47+
}
48+
2549
/// <summary>
2650
/// Download the specified range of WIP disc pages
2751
/// </summary>
@@ -30,8 +54,12 @@ public static async Task<List<int>> DownloadLastSubmitted(this RedumpClient clie
3054
/// <param name="forceDownload">True to force all downloads, false otherwise</param>
3155
/// <param name="minId">Starting ID for the range</param>
3256
/// <param name="maxId">Ending ID for the range (inclusive)</param>
33-
/// <returns>All disc IDs in last submitted range, empty on error</returns>
34-
public static async Task<List<int>> DownloadWIPRange(this RedumpClient client, string? outDir, bool forceDownload, int minId = 0, int maxId = 0)
57+
/// <returns>All WIP IDs that successfully downloaded, empty on error</returns>
58+
public static async Task<List<int>> DownloadWIPRange(this RedumpClient client,
59+
string? outDir,
60+
bool forceDownload,
61+
int minId = 0,
62+
int maxId = 0)
3563
{
3664
List<int> ids = [];
3765
for (int id = minId; id <= maxId; id++)

0 commit comments

Comments
 (0)