Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def loadInventoryFromSteam(self, app, context):
- import copy
- TradingCards = []
- result = None
- more = True
- start = 0
- Inventory = {}
- Descriptions = {}
- while more:
- result = None
- while result == None or unicode(result) == "null":
- result = downloadString("http://steamcommunity.com/profiles/" + unicode(self.SteamID64) + "/inventory/json/" + unicode(app) + "/" + unicode(context), {"start" : start}, {})
- temp = json.loads(result)
- resultJSON = copy.deepcopy(temp)
- #Unsucess is usually because of a private profile.
- if resultJSON["success"] == False:
- return []
- #Load more items
- if resultJSON["more"]:
- start = resultJSON["more_start"]
- else:
- more = False
- descriptionsJSON = resultJSON["rgDescriptions"]
- for desc in descriptionsJSON:
- Descriptions[descriptionsJSON[desc]["classid"]] = descriptionsJSON[desc]
- inventory = resultJSON["rgInventory"]
- for item in inventory:
- for desc in Descriptions:
- if desc == inventory[item]["classid"]:
- Item = inventory[item]
- Description = Descriptions[desc]
- if Item["id"] in Inventory.keys():
- print("test")
- Inventory[Item["id"]] = SteamInventory.Item(Item["id"], context, Description["classid"], Description["instanceid"], Item["amount"], copy.deepcopy(Description))
- #Put the data we got to the property
- if app not in self.Inventory.keys():
- self.Inventory[app] = {}
- self.Inventory[app][context] = {}
- for item in Inventory:
- self.Inventory[app][context][Inventory[item].itemid] = Inventory[item]
- return Inventory
Advertisement
Add Comment
Please, Sign In to add comment