deivit24 / python-steam-api

MIT License
25 stars 11 forks source link

`steam.apps.search_games` fails to convert `id` in `apps.py` when link has a list of ids #13

Closed sgjholt closed 6 months ago

sgjholt commented 8 months ago

Bug

I found a bug in steam.apps.search_games that occurred when I searched for Fallout 4 using the method. Here's an example:

Example

Running test_steam_api.py

# test_steam_api.py
from steam import Steam
from decouple import config
# Get steam api key loaded from .env
STEAM_API_KEY = config("STEAM_API_KEY")
# Connect to steam api
steam = Steam(STEAM_API_KEY)
# Search for Fallout 4 title
steam.apps.search_games("Fallout 4")

Error

Traceback (most recent call last):
  File "/Users/jam/.pyenv/versions/3.11.5/lib/python3.11/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jam/.pyenv/versions/3.11.5/lib/python3.11/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/Users/jam/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/Users/jam/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/Users/jam/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/jam/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jam/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/jam/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/Users/jam/Projects/steam_api_playground/test_steam_api.py", line 11, in <module>
    steam.apps.search_games("Fallout 4")
  File "/Users/jam/.local/share/virtualenvs/steam_api_playground-W4Haidyw/lib/python3.11/site-packages/steam/apps.py", line 111, in search_games
    app["id"] = int(string_id.replace("\\", "").replace('"', ""))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '377160,435870,435880,435881,480630,480631,490650'

Debugging Screens: Multi-Id Link is Unique

Debug screen 2 shows the entries in the debugger before the exception is thrown. It throws an error trying to convert the 3rd link (at index 2) which is the only entry with multiple ids. It seems that this edge case is not handled currently. I am not sure if this is unique to this title or not, I haven't tested any other examples.

Debug Screen 1

Screenshot 2023-10-28 at 1 00 12 PM

Debug Screen 2

Screenshot 2023-10-28 at 12 59 57 PM
AhmedSherifH commented 7 months ago

I've been having this issue too. Do you have any updates on it?

UnreleasedDev commented 7 months ago

@sgjholt @AhmedSherifH i submit a fix for this here #14 if you want to test and try it

sgjholt commented 7 months ago

@sgjholt @AhmedSherifH i submit a fix for this here #14 if you want to test and try it

Thanks, I will take a look!

deivit24 commented 6 months ago

Sorry for being late on this! Update the package to 1.2.1. The fix is there! Thank you @UnreleasedDev !!