Skip to content

Commit

Permalink
Merge pull request #78 from tylerbrawl/scauth-test
Browse files Browse the repository at this point in the history
Improved last played game checking.
  • Loading branch information
tylerbrawl authored Dec 18, 2019
2 parents f86bc4a + f78d991 commit 5f1841c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,17 @@ async def get_last_played_game(self, friend_name):
await self._refresh_credentials_social_club_light()
return await self.get_last_played_game(friend_name)
try:
last_played_ugc = resp_json['accounts'][0]['rockstarAccount']['lastUgcTitle']
# The last played game is always listed first in the ownedGames list.
last_played_ugc = resp_json['accounts'][0]['rockstarAccount']['gamesOwned'][0]['name']
title_id = get_game_title_id_from_ugc_title_id(last_played_ugc + "_PC")
if LOG_SENSITIVE_DATA:
log.debug(f"{friend_name}'s Last Played Game: "
f"{games_cache[title_id]['friendlyName'] if title_id else last_played_ugc}")
return UserPresence(PresenceState.Online,
game_id=str(games_cache[title_id]['rosTitleId']) if title_id else last_played_ugc,
in_game_status="Last Played Game")
except KeyError:
# If the lastUgcTitle key is not found in the JSON, then the user has not played any games. In this case, we
except IndexError:
# If a game is not found in the gamesOwned list, then the user has not played any games. In this case, we
# cannot be certain of their presence status.
if LOG_SENSITIVE_DATA:
log.warning(f"ROCKSTAR_LAST_PLAYED_WARNING: The user {friend_name} has not played any games!")
Expand Down

0 comments on commit 5f1841c

Please sign in to comment.