Skip to content

Commit

Permalink
hotfix to fix crashes due to private accounts and improve clarity of …
Browse files Browse the repository at this point in the history
…"User ID" input field

Closes #4
  • Loading branch information
TabulateJarl8 committed Dec 13, 2023
1 parent fbe89f1 commit a5d4313
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 6 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,16 @@ makepkg -si
## Requirements
This package is built on top of textual and aiohttp, and uses poetry to manage dependencies. To install dependencies locally, just run `poetry install` in the repository's directory.

## Private Steam Account Error
This error occurs if your game details are set to private in your privacy settings. First, double check that you're using the correct Steam ID or vanity URL. This is different from your display name. To make sure, you can directly copy your profile URL into Vapor and your Steam ID will be extracted. Your profile URL will look like `https://steamcommunity.com/id/<vanity_name>` or `https://steamcommunity.com/profiles/<steam_id>`.

If you've double checked that your account information is correct, please complete the following steps to fix this issue:

1. From Steam, click the user dropdown and select "View my profile"
1. Click the "Edit Profile" button
2. Click the "Privacy Settings" tab
3. Set "Game details" to Public
4. Uncheck the Always keep my total playtime private option

## Contributing
Contributions are welcomed! For bug fixes, improvements, or feature requests, feel free to open an issue or pull request.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vapor-steam"
version = "1.3.1"
version = "1.3.2"
description = "TUI program to check the ProtonDB compatibility of all the games of a Steam user."
authors = ["TabulateJarl8 <[email protected]>"]
license = "GPLv3"
Expand Down
8 changes: 6 additions & 2 deletions vapor/api_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Response,
SteamUserData,
)
from vapor.exceptions import InvalidIDError, UnauthorizedError
from vapor.exceptions import InvalidIDError, PrivateAccountError, UnauthorizedError


# typing classes
Expand Down Expand Up @@ -191,7 +191,11 @@ async def get_steam_user_data(api_key: str, id: str) -> SteamUserData:
if data.status == 401:
raise UnauthorizedError

games = json.loads(data.data)['response']['games']
data = json.loads(data.data)['response']
if 'games' not in data:
raise PrivateAccountError

games = data['games']
game_ratings = [
Game(
name=game['name'],
Expand Down
12 changes: 12 additions & 0 deletions vapor/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
CONFIG_DIR = user_config_path(appname='vapor', appauthor='tabulate', ensure_exists=True)
"""The config directory used to write files such as config and cache."""

PRIVATE_ACCOUNT_HELP_MESSAGE = """
Your Steam account is currently private. See README for more details.
Please change your Steam profile privacy settings:
1. From Steam, click the user dropdown and select "View my profile"
1. Click the "Edit Profile" button
2. Click the "Privacy Settings" tab
3. Set "Game details" to Public
4. Uncheck the Always keep my total playtime private option
""".strip()

_ANTI_CHEAT_COLORS: dict[str, str] = {
'Denied': 'red',
'Broken': 'dark_orange3',
Expand Down
4 changes: 4 additions & 0 deletions vapor/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ class InvalidIDError(Exception):

class UnauthorizedError(Exception):
"""If an invalid Steam API key is used, this error will be raised."""


class PrivateAccountError(Exception):
"""If an account is set to private."""
22 changes: 19 additions & 3 deletions vapor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
get_steam_user_data,
)
from vapor.config_handler import read_steam_api_key, write_steam_api_key
from vapor.data_structures import RATING_DICT, AntiCheatData, AntiCheatStatus
from vapor.exceptions import InvalidIDError, UnauthorizedError
from vapor.data_structures import (
PRIVATE_ACCOUNT_HELP_MESSAGE,
RATING_DICT,
AntiCheatData,
AntiCheatStatus,
)
from vapor.exceptions import InvalidIDError, PrivateAccountError, UnauthorizedError


class SteamApp(App):
Expand All @@ -31,7 +36,11 @@ def compose(self) -> ComposeResult:
id='api-key',
validators=Regex(r'[A-Z0-9]{32}'),
),
Input(placeholder='User ID', id='user-id', validators=Regex(r'.+')),
Input(
placeholder='Profile URL or Steam ID',
id='user-id',
validators=Regex(r'.+'),
),
id='input-container',
)
yield Center(Button('Check Profile', variant='primary'))
Expand Down Expand Up @@ -127,6 +136,13 @@ async def populate_table(self) -> None:
self.notify('Invalid Steam User ID', title='Error', severity='error')
except UnauthorizedError:
self.notify('Invalid Steam API Key', title='Error', severity='error')
except PrivateAccountError:
self.notify(
PRIVATE_ACCOUNT_HELP_MESSAGE,
title='Error',
severity='error',
timeout=15.0,
)
finally:
# re-enable Input widgets
for item in self.query(Input):
Expand Down

0 comments on commit a5d4313

Please sign in to comment.