deivit24 / python-steam-api

MIT License
25 stars 11 forks source link

Achievement details & unlock rate #32

Closed zeroquinc closed 1 month ago

zeroquinc commented 1 month ago

Hi,

I have this for example:

steam.apps.get_app_details("504230", filters="achievements")

And it returns this:

{
   "504230":{
      "success":true,
      "data":{
         "achievements":{
            "total":32,
            "highlighted":[
               {
                  "name":"Celeste",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/f8563120e18b88ff7e31b03ff6fcb61c5553b1ac.jpg"
               },
               {
                  "name":"Forsaken",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/6d16bf0629b862295a62b2d92ab22a94dc593903.jpg"
               },
               {
                  "name":"Archaeology",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/7544829d732b63de52eb0e68c796a68e8153c26f.jpg"
               },
               {
                  "name":"Checking Out",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/7e202a373754eac26194d75d6ba82e7fcc48ea42.jpg"
               },
               {
                  "name":"Breathe",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/fc3f2ae7d42ce92886c166aff6e9868b6dd9c518.jpg"
               },
               {
                  "name":"In the Mirror",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/902474b484af5d94aeaa22d74e3559c47e94beec.jpg"
               },
               {
                  "name":"Reflection",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/82f006e8c91ec81c8af98f7e5c59ad2ea1f8b0b1.jpg"
               },
               {
                  "name":"Strawberry Badge",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/64cffde21bf6fba1d3749e751a5772765f95357c.jpg"
               },
               {
                  "name":"Strawberry Medal",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/0e3b7b3e990ea0e212df36054e31521d29da21ca.jpg"
               },
               {
                  "name":"Impress Your Friends",
                  "path":"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/9b043fec21f1028d306f0908b401c86d8869c334.jpg"
               }
            ]
         }
      }
   }
}

Is it possible to add these things:

With apiName I mean the following, it returns this when I check for example:

user_achievements = steam.apps.get_user_achievements("redacted", "504230")

Returns:

{
   "playerstats":{
      "steamID":"redacted",
      "gameName":"Celeste",
      "achievements":[
         {
            "apiname":"CH7",
            "achieved":1,
            "unlocktime":1710068747
         },
         {
            "apiname":"CH1",
            "achieved":1,
            "unlocktime":1709924417
         },
         {
            "apiname":"CH2",
            "achieved":1,
            "unlocktime":1709925745
         },
         {
            "apiname":"CH3",
            "achieved":1,
            "unlocktime":1709935466
         },
         {
            "apiname":"CH4",
            "achieved":1,
            "unlocktime":1709984637
         },
         {
            "apiname":"CH5",
            "achieved":1,
            "unlocktime":1710006604
         },

But because the apiname isnt in the get_app_details I can't check these values to see which name / details belong to which unlocked achievement.

Also how come it only shows 9 achievements and not all the 32?

Thank you very much in advance.

deivit24 commented 1 month ago

Will take a look at this over the weekend! Vacation at the moment

zeroquinc commented 1 month ago

Will take a look at this over the weekend! Vacation at the moment

Cheers, maybe I'll try to do a pull request before the weekend.

Enjoy your holiday!

zeroquinc commented 1 month ago

This is what I had in mind:

{
   "playerstats":{
      "steamID":"redacted",
      "gameName":"Celeste",
      "achievements":[
         {
            "apiname":"CH6",
            "name":"Reflection",
            "details":"Complete Chapter 6"
            "unlocked_by":"6.434321%"
            "image": "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/504230/82f006e8c91ec81c8af98f7e5c59ad2ea1f8b0b1.jpg"
            "achieved":1,
            "unlocktime":1710068747
         },
zeroquinc commented 1 month ago

https://github.com/deivit24/python-steam-api/pull/18#event-12381819524

Seems like I want exactly this, the only pull request that didn't got merged :(

More info I found: https://stackoverflow.com/questions/24315841/optional-values-from-steam-web-api

deivit24 commented 1 month ago

@zeroquinc Hey wow ya I got a PR and asked for updates. Will make updates to this and get a release out tomorrow!

zeroquinc commented 1 month ago

@zeroquinc Hey wow ya I got a PR and asked for updates. Will make updates to this and get a release out tomorrow!

Thanks, in the meanwhile I created my own API translation for my project to see if it worked, and if you pass the "l" parameter you get the achievement details, only not the ones that are hidden, so that kinda sucks.

https://github.com/zeroquinc/Steamcord/blob/main/api/game.py

I kinda fixed that by scraping "completionists.me" website once and save the descriptions to a json.

https://github.com/zeroquinc/Steamcord/blob/main/src/steam/functions.py

deivit24 commented 1 month ago

@zeroquinc issue will be closed! In the new release