Jump to content
McKay Development
HolidayExplanation

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

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...