Jump to content


Photo
Question

Is there any way to get the name of the game, instead of appid?

node.js node-steam-user

  • Please log in to reply
2 replies to this topic

#1 HolidayExplanation

HolidayExplanation

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 17 August 2019 - 11:49 AM

Solution for getting appOwnershipChached apps' name instead of appid.

 

I got config.default_apps by using an empty Steam account to get the numerical list of apps each account has by default and on that line I compare that default list to the list of the fetched user account which might have some games and then filter to remove the default apps.

//get GAME LIST
client.on('appOwnershipCached', async() => {
    try {
        const appIDs = await client.getOwnedApps() 

        let gameList = appIDs.filter((game) => { // remove default apps from list
            return !config.default_apps.includes(game)
        })
        
        const appDetails = await client.getProductInfo(gameList, []) 
        let appData = appDetails.apps

        let arr = await Object.keys(appData).map(key => { // convert list to array
            return appData[key]
        })	

        let cleanGameList = []
        await arr.forEach(app => { // push only app names into array
            if (app.appinfo.common !== undefined) { // necessary only .common since .common.name gives TypeError
                cleanGameList.push(app.appinfo.common.name)
            }
        })  

        log(cleanGameList)
    } catch(err) {
        log(err)
    }
})

Well, I've been trying/searching different things for hours now without any sufficient results. I am trying to get the name of the app/game instead of the appid number via appOwnershipCached. I am actually trying to get the games in the users account instead of also apps and default apps that come with a Steam account. I managed to get the names with an npm package called appid, but it takes a while until it converts all of them since it's fetching it from Steam API, so unfortunately it's not an option and I've run out.

So I have two questions:

Is there a way to get an apps' name instead of appid?

Is there a way to get only the games without apps and default apps?

 

Edit: I actually managed to filter it to the point until I get only the games in my library. I basically filter default apps from the appOwnershipCached fetch of appIDs and then if the appID has a name, it puts it into the gameList array. But the problem is, some games seem not to have names, why is that?

For example: Rocket League only has { appid: '252590', public_only: '1' } on .appinfo...


OLD NOT WORKING

//get GAME LIST
client.on('appOwnershipCached', async() => {
    try {
        const appIDs = await client.getOwnedApps() 
        log(appIDs)

        let gameList = appIDs.filter((game) => {
            return !config.default_apps.includes(game)
        })
        log(gameList)

        accountData.games = await gameList
        // log("my games: " + accountData.games)
    
        const appDetails = await client.getProductInfo(gameList, [])

        // ROCKET LEAGUE TEST
        const rl = await client.getProductInfo([252590], [])
        log(rl.apps[252590].appinfo)
        //

        let appData = appDetails.apps
        // log(appData)

        let arr = await Object.keys(appData).map(key => {
            return appData[key]
        })	
        // log(arr) 

        let cleanGameList = []
        await arr.forEach(app => {
            if (app.appinfo.common.name != null) {
                // log(app.appinfo.common.name)
                console.log("list: ", cleanGameList)
                return cleanGameList.push(app.appinfo.common.name)
            }
            
        })  
    } catch(err) {
        log(err)
    }
})

Edited by HolidayExplanation, 18 August 2019 - 05:49 AM.


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,188 posts

Posted 17 August 2019 - 11:20 PM

Rocket League is 252950, not 252590.


  • HolidayExplanation likes this

#3 HolidayExplanation

HolidayExplanation

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 18 August 2019 - 05:35 AM

Thank you for your answer, Dr.. I realized the mistake later when debugging, but it didn't change much. The problem was a type error which would break the for each and not put all the items into gameList. I will clean it up and post it as a solution in the case that anyone happens to need.







Also tagged with one or more of these keywords: Question, node.js, node-steam-user

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users