steampy
steampy copied to clipboard
Add params in get_partner_inventory
OLD:
def get_partner_inventory(
self, partner_steam_id: str, game: GameOptions, merge: bool = True, count: int = 5000
) -> dict:
url = '/'.join((SteamUrl.COMMUNITY_URL, 'inventory', partner_steam_id, game.app_id, game.context_id))
params = {'l': 'english', 'count': count}
response_dict = self._session.get(url, params=params).json()
if response_dict is None or response_dict.get('success') != 1:
raise ApiException('Success value should be 1.')
return merge_items_with_descriptions_from_inventory(response_dict, game) if merge else response_dict
NEW:
def get_partner_inventory(
self, partner_steam_id: str, game: GameOptions, merge: bool = True, count: int = 5000, last_assetid: int = None
) -> dict:
url = '/'.join((SteamUrl.COMMUNITY_URL, 'inventory', partner_steam_id, game.app_id, game.context_id, ))
params = {'l': 'english', 'count': count, "start_assetid": f"start_assetid={last_assetid}" if last_assetid else ""}
response_dict = self._session.get(url, params=params).json()
if response_dict is None or response_dict.get('success') != 1:
raise ApiException('Success value should be 1.')
return merge_items_with_descriptions_from_inventory(response_dict, game) if merge else response_dict
What is this? And for which file?
Простите. Мой программист язык очень плохой. =) Спустя несколько часов тестов я понял что я пока что еще глуп что бы делать такие предложения, но проблема все же имеется оригинале. В общем и целом запрашивая инвентарь пользователя объемом более 5000 предметов мы получим только первые 5000. Что бы получить 5001 предмет, нам нужно знать last_assetid. Как его получить в steampy я не понял. Но знаю что дело в utils.py. Мы получаем только assets: value, а нужно получить ВЕСЬ json ответ, что бы в будущем использовать дополнительные парамеры.
translete G:
Sorry. My programmer language is very bad. =) After several hours of testing, I realized that I am still stupid to make such proposals, but the problem still exists in the original. In general, when requesting a user's inventory of more than 5000 items, we will only get the first 5000. To get 5001 items, we need to know the last_assetid. I don't understand how to get it in steampy. But I know that the problem is in utils.py. We only get assets: value, but we need to get the ALL json response in order to use additional parameters in the future.
Did you try to raise “count” argument which is 5000 now?
Did you try to raise “count” argument which is 5000 now?
No, the maximum value is count=5000. This is a steam request limit. I wanted to get an inventory that has more than 5000 items, for example 6000. To get 5001-6000 items, you need to know last_assetid and pass &start_assetid=last_assetid in the request
Could you give me an example account with 5000+ items on it, i'll try to solve it
https://steamcommunity.com/id/officialstmbot
Я написал свой парсер инвентаря. в котором проверяется "more_items". Также сделал примитивную защиту от ошибки 429.
Но топик не закрываю, так как считаю это недоработкой. Еще steampy требует обязательной авторизации для парсинга инвентаря, что не нужно.
I wrote my own inventory parser. in which 'more_items' is checked. I also made a primitive protection against error 429.
But I’m not closing the topic, because I don’t think it’s an improvement. Steampy also requires mandatory authorization to parse inventory, which is not necessary.