Skip to content

Commit

Permalink
add images, messages, subscriptioninfo
Browse files Browse the repository at this point in the history
  • Loading branch information
hictooth committed Jun 29, 2023
1 parent cd70635 commit bff03c2
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ dotnet publish -c Release --self-contained dragonrescue.sln
- active dragons
- rooms
- room items (I think this is eggs?)
- Images (of your dragons)
- Messages
- Subscription info

### What is not exported

Basically anything not on the above list, including but not limited to:

- Images (of your dragons)
- GetValuePairs
- Announcements
- Messages
- Subscription info
79 changes: 75 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@

/*
* TODO:
* - GetImage (s)
* - GetKeyValuePair (s)
* - GetAnnouncementsByUser
* - GetUserMessageQueue
* - GetSubscriptionInfo
*/

const string KEY = "56BB211B-CF06-48E1-9C1D-E40B5173D759";

string[] commandlineArgs = Environment.GetCommandLineArgs();
if (commandlineArgs.Length < 3) {
if (commandlineArgs.Length < 4) {
Console.WriteLine("Not enough args.\nUsage: ./dragonrescue <username> <password> <full_output_path>");
Environment.Exit(0);
}
string username = commandlineArgs[1];
string password = commandlineArgs[2];
Expand All @@ -39,6 +37,10 @@
string parentInfo = await GetUserInfoByApiToken(client, loginInfoObject.ApiToken);
WriteToFile(outputPath, "GetUserInfoByApiToken.xml", parentInfo);

Console.WriteLine("Fetching subscription information...");
string subscriptionInfo = await GetSubscriptionInfo(client, loginInfoObject.ApiToken);
WriteToFile(outputPath, "GetSubscriptionInfo.xml", subscriptionInfo);

Console.WriteLine("Fetching child profiles...");
string children = await GetDetailedChildList(client, loginInfoObject.ApiToken);
WriteToFile(outputPath, "GetDetailedChildList.xml", children);
Expand Down Expand Up @@ -97,6 +99,25 @@
string rooms = await GetUserRoomList(client, childApiToken, profile.ID);
WriteToChildFile(outputPath, profile.ID, "GetUserRoomList.xml", rooms);

Console.WriteLine(string.Format("Fetching messages for {0}...", profile.AvatarInfo.UserInfo.FirstName));
string messages = await GetUserMessageQueue(client, childApiToken);
WriteToChildFile(outputPath, profile.ID, "GetUserMessageQueue.xml", messages);

for (int i = 0; i < 500; i++) { // hard limit of 500 for this scrape, hopefully no one has more than that?
Console.WriteLine(string.Format("Fetching image slot {0} for {1}...", i, profile.AvatarInfo.UserInfo.FirstName));
string imageData = await GetImageData(client, childApiToken, i);
ImageData imageDataObject = XmlUtil.DeserializeXml<ImageData>(imageData);
if (imageDataObject is null || string.IsNullOrWhiteSpace(imageDataObject.ImageURL)) break;
WriteToChildFile(outputPath, profile.ID, String.Format("{0}-{1}", i, "GetImageData.xml"), imageData);

// now get the image itself
Console.WriteLine(string.Format("Downloading image {0} for {1}...", i, profile.AvatarInfo.UserInfo.FirstName));
string imageUrl = imageDataObject.ImageURL;
Uri uri = new Uri(imageUrl);
string filename = Path.GetFileName(uri.LocalPath);
DownloadFile(outputPath, filename, imageUrl);
}

UserRoomResponse roomsObject = XmlUtil.DeserializeXml<UserRoomResponse>(rooms);
foreach (UserRoom room in roomsObject.UserRoomList) {
if (room.RoomID is null) continue;
Expand All @@ -123,6 +144,13 @@ static void WriteToChildFile(string path, string childId, string name, string co
}
}

static void DownloadFile(string path, string name, string downloadUrl) {
string fullPath = Path.Join(path, name);
Console.WriteLine(fullPath);
var webClient = new WebClient();
webClient.DownloadFile(downloadUrl, fullPath);
}


static async Task<string> LoginParent(HttpClient client, string UserName, string Password, string key) {
ParentLoginData loginData = new ParentLoginData {
Expand Down Expand Up @@ -417,4 +445,47 @@ static async Task<string> GetSelectedRaisedPet(HttpClient client, string apiToke
var bodyRaw = await response.Content.ReadAsStringAsync();
return bodyRaw;
//return XmlUtil.DeserializeXml<RaisedPetData[]>(bodyRaw);
}


static async Task<string> GetUserMessageQueue(HttpClient client, string apiToken) {
var formContent = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("apiToken", apiToken),
new KeyValuePair<string, string>("apiKey", "b99f695c-7c6e-4e9b-b0f7-22034d799013"),
new KeyValuePair<string, string>("showOldMessages", "true"),
new KeyValuePair<string, string>("showDeletedMessages", "true"),
});

var response = await client.PostAsync("https://common.api.jumpstart.com/MessagingWebService.asmx/GetUserMessageQueue", formContent);
var bodyRaw = await response.Content.ReadAsStringAsync();
return bodyRaw;
//return XmlUtil.DeserializeXml<ArrayOfMessageInfo>(bodyRaw);
}


static async Task<string> GetSubscriptionInfo(HttpClient client, string apiToken) {
var formContent = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("apiToken", apiToken),
new KeyValuePair<string, string>("apiKey", "b99f695c-7c6e-4e9b-b0f7-22034d799013"),
});

var response = await client.PostAsync("https://common.api.jumpstart.com/MembershipWebService.asmx/GetSubscriptionInfo", formContent);
var bodyRaw = await response.Content.ReadAsStringAsync();
return bodyRaw;
//return XmlUtil.DeserializeXml<ArrayOfMessageInfo>(bodyRaw);
}


static async Task<string> GetImageData(HttpClient client, string apiToken, int imageSlot) {
var formContent = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("apiToken", apiToken),
new KeyValuePair<string, string>("apiKey", "b99f695c-7c6e-4e9b-b0f7-22034d799013"),
new KeyValuePair<string, string>("ImageType", "EggColor"),
new KeyValuePair<string, string>("ImageSlot", imageSlot.ToString()),
});

var response = await client.PostAsync("https://contentserver.api.jumpstart.com/ContentWebService.asmx/GetImage", formContent);
var bodyRaw = await response.Content.ReadAsStringAsync();
return bodyRaw;
//return XmlUtil.DeserializeXml<ImageData>(bodyRaw);
}

0 comments on commit bff03c2

Please sign in to comment.