Created
February 4, 2020 22:16
-
-
Save jaecktec/34cb65d4663d3719e74b1aff8eb85234 to your computer and use it in GitHub Desktop.
steam gforce now query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: node query.js STEAM_API_KEY STEAM_ACCOUNT_ID | |
const fetch = function (url) { | |
// return new pending promise | |
return new Promise((resolve, reject) => { | |
// select http or https module, depending on reqested url | |
const lib = url.startsWith('https') ? require('https') : require('http'); | |
const request = lib.get(url, (response) => { | |
// handle http errors | |
if (response.statusCode < 200 || response.statusCode > 299) { | |
reject(new Error('Failed to load page, status code: ' + response.statusCode)); | |
} | |
// temporary data holder | |
const body = []; | |
// on every content chunk, push it to the data array | |
response.on('data', (chunk) => body.push(chunk)); | |
// we are done, resolve promise with those joined chunks | |
response.on('end', () => resolve(body.join(''))); | |
}); | |
// handle connection errors of the request | |
request.on('error', (err) => reject(err)) | |
}) | |
}; | |
const steamApiKey = process.argv[2]; | |
const steamAccountId = process.argv[3]; | |
(async () => { | |
const last = a => a[a.length - 1]; | |
const supportedGames = JSON.parse(await fetch('https://static.nvidiagrid.net/supported-public-game-list/gfnpc.json?JSON')) | |
const steamGames = JSON.parse(await fetch(`http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=${steamApiKey}&steamid=${steamAccountId}&format=json`)) | |
const steamAppIds = steamGames.response.games.map(it => it.appid) | |
supportedGames | |
.filter(it => it.steamUrl) | |
.filter(it => steamAppIds.indexOf(parseInt(last(it.steamUrl.split('/')))) >= 0) | |
.forEach(it => console.log(`${it.title} is supported, fully optimized: ${it.isFullyOptimized}`)) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment