Rebuild bot download
This commit is contained in:
parent
81c0130792
commit
c914bc1cb8
1 changed files with 18 additions and 21 deletions
|
@ -10,9 +10,7 @@ using RC2BotArchiver;
|
|||
|
||||
Console.WriteLine("Hello, World!");
|
||||
|
||||
FixCRF2Archive.FixIt();
|
||||
|
||||
/*var client = new HttpClient();
|
||||
var client = new HttpClient();
|
||||
|
||||
async Task<JsonElement?> GetResponse(HttpResponseMessage result, string url)
|
||||
{
|
||||
|
@ -68,38 +66,41 @@ var jwt = responseJson.Value.GetProperty("Token");
|
|||
payload = new ExpandoObject();
|
||||
payload.Token = responseJson.Value.GetProperty("Token");
|
||||
payload.ClientVersion = "100.0";
|
||||
responseJson = await Post("https://progression.development.robocraft.org/login/fj", payload);
|
||||
responseJson = await Post("https://services-test-robocraft2.robocraft.org/login", payload);
|
||||
var progressToken = responseJson.Value.GetProperty("token").GetString();
|
||||
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", progressToken);
|
||||
|
||||
const string factoryUrl = "https://factory.development.robocraft.org";
|
||||
const string factoryUrl = "https://services-test-robocraft2.robocraft.org";
|
||||
|
||||
int page = 57;
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"Getting page {page}");
|
||||
responseJson = await Get(factoryUrl + $"/v1/foundry/search?page={page}&count=10");
|
||||
Console.WriteLine($"Getting bots...");
|
||||
responseJson = await Get(factoryUrl + $"/garage");
|
||||
if (!responseJson.HasValue) throw new Exception("Failed to get robots!");
|
||||
var results = responseJson.Value.GetProperty("results");
|
||||
if (results.GetArrayLength() == 0) break;
|
||||
foreach (var result in results.EnumerateArray())
|
||||
var garage = responseJson.Value.GetProperty("garage");
|
||||
var bays = garage.GetProperty("bays");
|
||||
if (bays.GetArrayLength() == 0) break;
|
||||
foreach (var robot in bays.EnumerateArray())
|
||||
{
|
||||
var robot = result.GetProperty("robot");
|
||||
var dirPath = Path.Combine("robots", robot.GetProperty("id").GetString()!);
|
||||
Directory.CreateDirectory(dirPath);
|
||||
File.WriteAllText(Path.Combine(dirPath, "metadata.json"), robot.GetRawText());
|
||||
responseJson = await Get(factoryUrl + "/v1/foundry/vehicles/" + robot.GetProperty("id"));
|
||||
responseJson = await Get(factoryUrl + "/garage/" + robot.GetProperty("id") + "/blockData");
|
||||
if (!responseJson.HasValue) throw new Exception($"Could not get bot {robot.GetProperty("name")}");
|
||||
File.WriteAllText(Path.Combine(dirPath, "robotData.json"), responseJson.Value.GetRawText());
|
||||
Console.WriteLine($"Saved {robot.GetProperty("name")} by {robot.GetProperty("creatorName")}");
|
||||
var robotBase64 = responseJson.Value.GetProperty("robotBlockData").GetString()!;
|
||||
File.WriteAllBytes(Path.Combine(dirPath, "robot.rc2"), Convert.FromBase64String(robotBase64));
|
||||
responseJson = await Get(factoryUrl + "/garage/" + robot.GetProperty("id") + "/imageData");
|
||||
if (!responseJson.HasValue) throw new Exception($"Could not get bot {robot.GetProperty("name")} image");
|
||||
var imageBase64 = responseJson.Value.GetProperty("robotImageData").GetString()!;
|
||||
File.WriteAllBytes(Path.Combine(dirPath, "image.png"), Convert.FromBase64String(imageBase64));
|
||||
Console.WriteLine($"Saved {robot.GetProperty("name")}");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
page++;
|
||||
break;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -109,7 +110,3 @@ while (true)
|
|||
Thread.Sleep(100000);
|
||||
}
|
||||
}
|
||||
|
||||
await DownloadImages.DoIt(client);*/
|
||||
|
||||
// TODO: Chart of amount of bots on CRF by date & amount of starter bots
|
||||
|
|
Loading…
Reference in a new issue