Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch SteamGridDB assets when adding game to Steam #3543

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

EmoonX
Copy link
Contributor

@EmoonX EmoonX commented Oct 21, 2024

Description

As of now, when using the "Add to Steam" feature, games are added to Steam in a barebones state. This PR improves upon that by fuzzy-searching the game title (program name) on SteamGridDB and, when available, downloading the respective assets and saving them to the designated user directory (.../steam/userdata/<user_id>/config/grid); in a similar vein to what happens when using Steam ROM Manager.

Since Steam relies on appIDs for game identification, one is now generated by a hash method (for uniqueness) and saved to shortcuts.vdf. Same appID is then used for naming downloaded assets.

Makes use of steamgrid-proxy, in particular the changes introduced by bottlesdevs/steamgrid-proxy#1 and bottlesdevs/steamgrid-proxy#2. However, these don't seem to be in production (https://steamgrid.usebottles.com/api) yet, so the only way to currently test it is by running the API webserver locally.

Further improvements?

SteamGridDB search can occasionally fail or even return the wrong match. Perhaps one way to solve that would be adding a Custom SteamGridDB Game ID setting for individual programs. Will wait for further feedback.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

First of all, make sure steamgrid-proxy is running, on the correct port and with the right SteamGridDB API key.

Add a game executable to a bottle, renaming it if needed. Then right click -> Add to Steam. Open (or restart) Steam as needed. All the available assets (grid, hgrid, hero, logo and icon) should be loaded as expected.

You can check for match correctness by comparing it to the Add to Library option: if the latter produces a nonempty grid for Bottles's library, then likewise both it and its sibling assets should be visible on Steam.

  • before:
    image
    image

  • after:
    image
    image

Copy link
Contributor

Pylint result on modfied files:
************* Module bottles.backend.managers.steam
bottles/backend/managers/steam.py:565:110: C0303: Trailing whitespace (trailing-whitespace)
bottles/backend/managers/steam.py:111:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
bottles/backend/managers/steam.py:138:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
bottles/backend/managers/steam.py:173:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
bottles/backend/managers/steam.py:190:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
bottles/backend/managers/steam.py:204:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
bottles/backend/managers/steam.py:412:8: C0206: Consider iterating with .items() (consider-using-dict-items)
bottles/backend/managers/steam.py:580:20: W0702: No exception type(s) specified (bare-except)
bottles/backend/managers/steam.py:24:0: C0411: standard import "datetime.datetime" should be placed before third party import "crc32c.crc32c" (wrong-import-order)
bottles/backend/managers/steam.py:25:0: C0411: standard import "functools.lru_cache" should be placed before third party import "crc32c.crc32c" (wrong-import-order)
bottles/backend/managers/steam.py:26:0: C0411: standard import "glob.glob" should be placed before third party import "crc32c.crc32c" (wrong-import-order)
bottles/backend/managers/steam.py:27:0: C0411: standard import "pathlib.Path" should be placed before third party import "crc32c.crc32c" (wrong-import-order)
bottles/backend/managers/steam.py:28:0: C0411: standard import "typing.Union" should be placed before third party import "crc32c.crc32c" (wrong-import-order)
************* Module bottles.backend.managers.steamgriddb
bottles/backend/managers/steamgriddb.py:41:0: C0303: Trailing whitespace (trailing-whitespace)
bottles/backend/managers/steamgriddb.py:71:0: C0303: Trailing whitespace (trailing-whitespace)
bottles/backend/managers/steamgriddb.py:73:0: C0303: Trailing whitespace (trailing-whitespace)
bottles/backend/managers/steamgriddb.py:36:8: W0702: No exception type(s) specified (bare-except)
bottles/backend/managers/steamgriddb.py:35:18: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
bottles/backend/managers/steamgriddb.py:32:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
bottles/backend/managers/steamgriddb.py:48:8: W0702: No exception type(s) specified (bare-except)
bottles/backend/managers/steamgriddb.py:47:18: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
bottles/backend/managers/steamgriddb.py:43:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
bottles/backend/managers/steamgriddb.py:66:16: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
bottles/backend/managers/steamgriddb.py:56:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
bottles/backend/managers/steamgriddb.py:80:16: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
bottles/backend/managers/steamgriddb.py:75:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant