Skip to content

Commit

Permalink
Merge pull request #408 from Revadike/feature-legacycdkeysdumper-example
Browse files Browse the repository at this point in the history
Add Legacy CD Keys Dumper Example
  • Loading branch information
DoctorMcKay authored Sep 3, 2024
2 parents 94a34b8 + a565e35 commit 42747e5
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions examples/legacycdkeysdumper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const SteamUser = require("steam-user");

Check failure on line 1 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Strings must use singlequote
const fs = require("fs");

Check failure on line 2 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Strings must use singlequote

const credentials = {
accountName: "username", // your steam username

Check failure on line 5 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Expected indentation of 1 tab but found 4 spaces

Check failure on line 5 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Strings must use singlequote
password: "password", // your steam password

Check failure on line 6 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Expected indentation of 1 tab but found 4 spaces

Check failure on line 6 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Strings must use singlequote
};

const client = new SteamUser({
enablePicsCache: true,

Check failure on line 10 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Expected indentation of 1 tab but found 4 spaces
});

client.on("loggedOn", () => {

Check failure on line 13 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Strings must use singlequote
console.log("Logged on");

Check failure on line 14 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Expected indentation of 1 tab but found 4 spaces

Check failure on line 14 in examples/legacycdkeysdumper.js

View workflow job for this annotation

GitHub Actions / lint / lint

Strings must use singlequote
});

client.on("ownershipCached", async () => {
let apps = client.getOwnedApps({
excludeExpiring: false,
excludeFree: false,
excludeShared: false
}).filter(appid => {
// these keys should indicate presence of a legacy cd key
return [
"hadthirdpartycdkey",
"legacykeydisklocation",
"legacykeyfromapp",
"legacykeylinkedexternally",
"legacykeyproofofpurchaseticket",
"legacykeyregistrationmethod",
"legacykeyregistrylocation",
"showcdkeyinmenu",
"showcdkeyonlaunch",
"supportscdkeycopytoclipboard",
"thirdpartycdkey",
].some((key) => Object.keys((client.picsCache
&& client.picsCache.apps[appid]
&& client.picsCache.apps[appid].appinfo
&& client.picsCache.apps[appid].appinfo.extended) || {}).map((k) => k.toLowerCase())
.includes(key));
});

console.log(`Requesting legacy cd keys for ${apps.length} owned apps...`);
let keys = {};
for (let appid of apps) {
try {
let { key } = await client.getLegacyGameKey(appid);
keys[appid] = key;
} catch (err) {
if (err.eresult !== SteamUser.EResult.Fail) { // usually just means no cd key present
console.error(`App: ${appid}`, err);
}
}
}
fs.writeFileSync("legacy_keys.json", JSON.stringify(keys, null, 4));
console.log("Done! Logging off...");
client.logOff();
});

client.on("disconnected", () => process.exit(0));

credentials.logonID = Math.round(Date.now() / 1000); // To avoid getting kicked by LogonSessionReplaced
client.logOn(credentials);

0 comments on commit 42747e5

Please sign in to comment.