def get_user_achievements(username, gameid, timeout=10, be_specific=False):
"""Gets information about a specific user's achievements for a specific game
Args:
username (str): the id or name of the user you want the achievements for
gameid (str): the id or name of the game you want the achievements for
timeout (int): the amount of time before aiohttp raises a timeout error
Returns:
UserAchievement: the user achievements found"""
if not is_integer(username):
username = yield from search_for_userid(username, timeout=timeout, be_specific=be_specific)
if not is_integer(gameid):
gameid, gamename = yield from get_app(gameid, timeout=timeout)
else:
gamename = "???"
_check_key_set()
if username is not None and gameid is not None:
with aiohttp.ClientSession() as session:
with aiohttp.Timeout(timeout):
resp = yield from session.get("http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid=" + gameid + "&key=" + STEAM_KEY + "&steamid=" + username)
data = yield from resp.json()
if "playerstats" in data and "achievements" in data["playerstats"]:
return UserAchievements(gameid, gamename, data["playerstats"]["achievements"])
评论列表
文章目录