Skip to content

Commit 53b2246

Browse files
committed
Updated code for user assets to use faster atom feeds
1 parent 9f956b1 commit 53b2246

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// If you have changed target frameworks, make sure to update the program path.
1313
"program": "${workspaceFolder}/console/bin/Debug/net5.0/SporeDownloader.dll",
1414
"args": [
15-
"sporecast",
16-
"501087975247"
15+
"user",
16+
"DOGC_Kyle"
1717
],
1818
"cwd": "${workspaceFolder}/console",
1919
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

library/SporeUser.cs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,25 @@ public Queue<long> getAllAssetIds()
3232

3333
var assetIds = new Queue<long>();
3434

35-
for (int i = 0; ; i += 500)
36-
{
37-
var doc = server.getAssetsForUser(UserName, i, 500).Element("assets");
35+
var doc = server.getAssetsForUserFeed(UserName).Element("{http://www.w3.org/2005/Atom}feed");
3836

39-
if(doc is null)
40-
{
41-
break;
42-
}
43-
44-
foreach (var asset in doc.Elements("asset"))
37+
if (doc is not null)
38+
{
39+
foreach (var asset in doc.Elements("{http://www.w3.org/2005/Atom}entry"))
4540
{
46-
long assetId = long.Parse(asset.Element("id")!.Value);
41+
string entryId = asset.Element("{http://www.w3.org/2005/Atom}id")!.Value;
42+
long assetId = long.Parse(entryId.Split('/')[1]);
4743

4844
assetIds.Enqueue(assetId);
4945

5046
Console.WriteLine($"Found asset ID {assetId} for user {UserName}");
5147
}
52-
53-
// Check if the number of retrieved creations is less than 500, if it is, exit loop
54-
int retrievedCount = int.Parse(doc.Element("count")!.Value);
55-
if (retrievedCount < 500) break;
56-
// Pause for a second, so we don't upset the server
57-
else Thread.Sleep(1000);
48+
Console.WriteLine($"Found {assetIds.Count} assets for user {UserName}");
49+
}
50+
else
51+
{
52+
Console.WriteLine($"Found no assets for user {UserName}, feed did not exist");
5853
}
59-
60-
Console.WriteLine($"Found {assetIds.Count} assets for user {UserName}");
6154

6255
return assetIds;
6356
}
@@ -78,14 +71,14 @@ public void downloadAllAssets(String filePath)
7871
foreach (var id in assetIds)
7972
{
8073
server.downloadAssetPng(id, filePath + id + ".png");
81-
try
74+
/*try
8275
{
8376
server.getAssetInfo(id).Save(filePath + id + "_meta.xml");
8477
}
8578
catch (System.Xml.XmlException)
8679
{
8780
Console.WriteLine($"Asset ID {id} for user {UserName} has invalid data in its Spore.com XML data, this data will not be saved");
88-
}
81+
}*/
8982

9083
Console.WriteLine($"Saved asset ID {id} for user {UserName}");
9184
}

0 commit comments

Comments
 (0)