def get_product_info(self, apps=None, packages=None): message = msg_base.ProtobufMessage(steammessages_clientserver_pb2.CMsgPICSProductInfoRequest, EMsg.PICSProductInfoRequest) if apps: for app in apps: app_info = message.body.apps.add() app_info.only_public = False if isinstance(app, tuple): app_info.appid, app_info.access_token = app else: app_info.appid = app if packages: for package in packages: package_info = message.body.packages.add() if isinstance(package, tuple): package_info.appid, package_info.access_token = package else: package_info.packageid = package message.body.meta_data_only = False response = self.client.wait_for_job(message, EMsg.PICSProductInfoResponse) for app in response.body.apps: self.app_cache[app.appid] = vdf.loads(app.buffer)['appinfo'] for package in response.body.packages: kv = vdf.loadbinary(package.buffer[4:]) self.package_cache[package.packageid] = kv[0][str(package.packageid)] return response.body
def initialize(self): if self.type == 'CDN': return True self.session_key = CryptoUtil.create_session_key() crypted_key = CryptoUtil.rsa_encrypt(self.session_key) url = "http://%s:%s/initsession/" % (self.host, self.port) payload = dict(sessionkey = crypted_key) if self.app_ticket: payload['appticket'] = CryptoUtil.symmetric_encrypt(self.app_ticket, self.session_key) else: payload['anonymoususer'] = 1 payload['steamid'] = self.steamid.steamid r = self.session.post(url, payload) if r.status_code != 200: return False sessionkv = vdf.loads(r.content)['response'] self.csid = sessionkv['csid'] self.session_id = int(sessionkv['sessionid']) & 0xFFFFFFFFFFFFFFFF self.req_counter = int(sessionkv['req-counter']) return True
def fetch_server_list(host, port, cell_id): url = "http://%s:%d/serverlist/%d/%d/" % (host, port, cell_id, 20) r = requests.get(url) serverkv = vdf.loads(r.content) if serverkv.get('deferred') == '1': return None servers = [] for id, child in serverkv['serverlist'].iteritems(): if child.get('host').find(';')> 0: (h, p) = child.get('host').split(':') else: (h, p) = child.get('host'), 80 load = child.get('weightedload') servers.append((h, p, load, child.get('type'))) return sorted(servers, key=itemgetter(2))
def fetch_server_list(host, port, cell_id): url = "http://%s:%d/serverlist/%d/%d/" % (host, port, cell_id, 20) r = requests.get(url) serverkv = vdf.loads(r.content) if serverkv.get("deferred") == "1": return None servers = [] for id, child in serverkv["serverlist"].iteritems(): if child.get("host").find(";") > 0: (h, p) = child.get("host").split(":") else: (h, p) = child.get("host"), 80 load = child.get("weightedload") servers.append((h, p, load, child.get("type"))) return sorted(servers, key=itemgetter(2))
def get_product_info(self, apps=None, packages=None): message = msg_base.ProtobufMessage( steammessages_clientserver_pb2.CMsgPICSProductInfoRequest, EMsg.PICSProductInfoRequest) if apps: for app in apps: app_info = message.body.apps.add() app_info.only_public = False if isinstance(app, tuple): app_info.appid, app_info.access_token = app else: app_info.appid = app if packages: for package in packages: package_info = message.body.packages.add() if isinstance(package, tuple): package_info.appid, package_info.access_token = package else: package_info.packageid = package message.body.meta_data_only = False response = self.client.wait_for_job(message, EMsg.PICSProductInfoResponse) for app in response.body.apps: self.app_cache[app.appid] = vdf.loads(app.buffer)['appinfo'] for package in response.body.packages: kv = vdf.loadbinary(package.buffer[4:]) self.package_cache[package.packageid] = kv[0][str( package.packageid)] return response.body