Created
August 15, 2020 08:27
-
-
Save ogawa0071/35e86de0160676a55a44550048b3113e to your computer and use it in GitHub Desktop.
steam-games-list
This file contains hidden or 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
| import axios from "axios"; | |
| // import papaparse from "papaparse"; | |
| import * as fs from "fs"; | |
| import retry from "async-retry"; | |
| // const startId = 32469; | |
| // const startId = 15669; | |
| // const startId = 450650; | |
| // const startId = 445502; | |
| // const startId = 432450; | |
| // const startId = 429881; | |
| const startId = 420450; | |
| (async () => { | |
| let apps: { appid: number; name: string }[] = []; | |
| if (!startId) { | |
| const appList = ( | |
| await axios.get("https://api.steampowered.com/ISteamApps/GetAppList/v2/") | |
| ).data; | |
| apps = appList.applist.apps; | |
| await fs.promises.writeFile("apps.json", JSON.stringify(apps, null, 2)); | |
| // await fs.promises.writeFile("appsData.json", "["); | |
| } else { | |
| const appsFile: { appid: number; name: string }[] = JSON.parse( | |
| await fs.promises.readFile("apps.json", "utf-8") | |
| ); | |
| const startIndex = appsFile.findIndex((array) => array.appid === startId); | |
| apps = appsFile.slice(startIndex); | |
| } | |
| for (const app of apps) { | |
| const id = app.appid; | |
| await retry(async () => { | |
| const response = await axios.get( | |
| `https://store.steampowered.com/api/appdetails?appids=${id}` | |
| ); | |
| const data: { [id: string]: { success: boolean; data: any } } = | |
| response.data; | |
| if (data[id].success === true) { | |
| const appData: {} = data[id].data; | |
| await fs.promises.appendFile( | |
| "appsData.json", | |
| `${JSON.stringify(appData)},` | |
| ); | |
| console.log(`Succeeded: ${id}`); | |
| } else { | |
| console.log(`Failed: ${id}`); | |
| } | |
| }); | |
| } | |
| // await fs.promises.appendFile("appsData.json", "]"); | |
| // papaparse.unparse(); | |
| })(); |
This file contains hidden or 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
| { | |
| "dependencies": { | |
| "async-retry": "^1.3.1", | |
| "axios": "^0.19.2", | |
| "papaparse": "^5.2.0" | |
| }, | |
| "devDependencies": { | |
| "@types/async-retry": "^1.4.2", | |
| "@types/papaparse": "^5.0.4" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment