Extract robot data

The parent ID needs to be zeroed out instead of null
The thumbnail naming needed a fix
This commit is contained in:
Norbi Peti 2024-05-14 20:06:28 +02:00
parent 89908b95e7
commit 231cc0f7c0
2 changed files with 3 additions and 1 deletions

View file

@ -15,7 +15,7 @@ public static class DownloadImages
if (url is null) continue;
var response = await client.GetAsync(url);
await using var stream = await response.Content.ReadAsStreamAsync();
await using var fs = File.OpenWrite(Path.Combine(dir, "thumbnail.jpg"));
await using var fs = File.OpenWrite(Path.Combine(dir, "thumbnail.jpeg"));
await stream.CopyToAsync(fs);
Console.WriteLine($"Saved image for {doc.RootElement.GetProperty("name")}");
}

View file

@ -84,6 +84,8 @@ foreach (var result in results.EnumerateArray())
responseJson = await Get(factoryUrl + "/v1/foundry/vehicles/" + robot.GetProperty("id"));
if (!responseJson.HasValue) throw new Exception($"Could not get bot {robot.GetProperty("name")}");
File.WriteAllText(Path.Combine(dirPath, "robotData.json"), responseJson.Value.GetRawText());
var data = responseJson.Value.GetProperty("data").GetString()!;
File.WriteAllBytes(Path.Combine(dirPath, "robot.rc2"), Convert.FromBase64String(data));
Console.WriteLine($"Saved {robot.GetProperty("name")} by {robot.GetProperty("creatorName")}");
Thread.Sleep(100);
}