Skip to content

Commit

Permalink
Client - Fix get_steam_id (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
makarworld authored Sep 28, 2023
1 parent 75f02b0 commit fc3267b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion steampy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_login_cookies(self, cookies: dict) -> None:
def get_steam_id(self) -> int:
url = SteamUrl.COMMUNITY_URL
response = self._session.get(url)
steam_id = re.match(r'g_steamID = "(\d+)";', response.text)
steam_id = re.search(r'g_steamID = "(\d+)";', response.text)
if steam_id:
return int(steam_id.group(1))
else:
Expand Down
5 changes: 5 additions & 0 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def setUpClass(cls):
dirname = os.path.dirname(os.path.abspath(__file__))
cls.steam_guard_file = dirname + '/../secrets/Steamguard.txt'

def test_get_steam_id(self):
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
self.assertTrue(client.get_steam_id() == int(self.steam_guard_file["Session"]["SteamID"]))

def test_login(self):
client = SteamClient(self.credentials.api_key)
client.login(self.credentials.login, self.credentials.password, self.steam_guard_file)
Expand Down

0 comments on commit fc3267b

Please sign in to comment.