54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
|
#! /usr/bin/env node
|
||
|
|
||
|
const STEAM_API_KEY = process.env.STEAM_API_KEY;
|
||
|
|
||
|
if (!STEAM_API_KEY) {
|
||
|
console.error(
|
||
|
"The STEAM_API_KEY environment variale should contain your Steam API key."
|
||
|
);
|
||
|
console.error("See: https://steamcommunity.com/dev/apikey");
|
||
|
process.exit(1);
|
||
|
}
|
||
|
|
||
|
const steam = new (require("steamapi"))(STEAM_API_KEY);
|
||
|
|
||
|
const STEAM_PROFILE_ID = process.env.STEAM_PROFILE_ID;
|
||
|
|
||
|
if (!STEAM_PROFILE_ID) {
|
||
|
console.error("The STEAM_PROFILE_ID environment variable is required.");
|
||
|
process.exit(1);
|
||
|
}
|
||
|
|
||
|
const skipGames = [];
|
||
|
|
||
|
if (process.env.SKIP_GAMES) {
|
||
|
process.env.SKIP_GAMES.split(",")
|
||
|
.map((game) => game.trim())
|
||
|
.forEach((game) => {
|
||
|
skipGames.push(game);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function shouldSkip(gameId, gameTitle) {
|
||
|
return (
|
||
|
// We could be comparing strings against numbers here, that's fine
|
||
|
skipGames.find((game) => game == gameId || game == gameTitle) !== undefined
|
||
|
);
|
||
|
}
|
||
|
|
||
|
const shouldValidate = !!process.env.FORCE_VALIDATE;
|
||
|
|
||
|
steam.getUserOwnedGames(STEAM_PROFILE_ID).then((games) =>
|
||
|
games
|
||
|
.filter((game) => !shouldSkip(game.appID, game.name))
|
||
|
.sort((a, b) => a.appID - b.appID)
|
||
|
.forEach((game) => {
|
||
|
console.log(
|
||
|
`// ${game.name} - https://store.steampowered.com/app/${game.appID}`
|
||
|
);
|
||
|
console.log(
|
||
|
`app_update ${game.appID}${shouldValidate ? " -validate" : ""}`
|
||
|
);
|
||
|
})
|
||
|
);
|