mirror of
https://github.com/SabreTools/SabreTools.RedumpLib.git
synced 2026-07-08 18:16:25 +00:00
70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SabreTools.RedumpLib.Legacy.Web
|
|
{
|
|
/// <summary>
|
|
/// Contains logic for dealing with WIP queue
|
|
/// </summary>
|
|
public static class WIP
|
|
{
|
|
/// <summary>
|
|
/// Download the last submitted WIP disc pages
|
|
/// </summary>
|
|
/// <param name="client">RedumpClient for connectivity</param>
|
|
/// <param name="outDir">Output directory to save data to</param>
|
|
/// <returns>All disc IDs in last submitted range, empty on error</returns>
|
|
public static async Task<List<int>> DownloadLastSubmitted(this Client client, string? outDir)
|
|
{
|
|
return await client.CheckSingleWIPPage(outDir) ?? [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Download the specified set of WIP disc pages
|
|
/// </summary>
|
|
/// <param name="client">RedumpClient for connectivity</param>
|
|
/// <param name="wipIds">Set of WIP IDs to download</param>
|
|
/// <param name="outDir">Output directory to save data to</param>
|
|
/// <returns>All WIP IDs in last submitted range, empty on error</returns>
|
|
public static async Task<List<int>> DownloadWIPSet(this Client client, List<int> wipIds, string? outDir)
|
|
{
|
|
List<int> ids = [];
|
|
foreach (int id in wipIds)
|
|
{
|
|
bool downloaded = await client.DownloadSingleWIPID(id, outDir, rename: true);
|
|
if (downloaded)
|
|
{
|
|
ids.Add(id);
|
|
DelayHelper.DelayRandom();
|
|
}
|
|
}
|
|
|
|
return ids;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Download the specified range of WIP disc pages
|
|
/// </summary>
|
|
/// <param name="client">RedumpClient for connectivity</param>
|
|
/// <param name="outDir">Output directory to save data to</param>
|
|
/// <param name="minId">Starting ID for the range</param>
|
|
/// <param name="maxId">Ending ID for the range (inclusive)</param>
|
|
/// <returns>All WIP IDs that successfully downloaded, empty on error</returns>
|
|
public static async Task<List<int>> DownloadWIPRange(this Client client, string? outDir, int minId, int maxId)
|
|
{
|
|
List<int> ids = [];
|
|
for (int id = minId; id <= maxId; id++)
|
|
{
|
|
bool downloaded = await client.DownloadSingleWIPID(id, outDir, rename: true);
|
|
if (downloaded)
|
|
{
|
|
ids.Add(id);
|
|
DelayHelper.DelayRandom();
|
|
}
|
|
}
|
|
|
|
return ids;
|
|
}
|
|
}
|
|
}
|