Skip to content

Use hasheous as igdb proxy #1997

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

Merged
merged 8 commits into from
Jul 6, 2025
Merged

Use hasheous as igdb proxy #1997

merged 8 commits into from
Jul 6, 2025

Conversation

gantoine
Copy link
Member

@gantoine gantoine commented Jun 18, 2025

Description
Explain the changes or enhancements you are proposing with this pull request.

This PR uses hasheous as a metadata proxy for games with IGDB matches. This means that users won't have to setup their own IGDB API keys and account to fetch (most) metadata, as hasheous will proxy the important ones.

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Copy link

trunk-io bot commented Jun 18, 2025

Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information.

Copy link

github-actions bot commented Jun 18, 2025

Test Results

91 tests   91 ✅  29s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit 0e5a486.

♻️ This comment has been updated with latest results.

@gantoine gantoine marked this pull request as ready for review July 5, 2025 23:08
@gantoine gantoine requested review from Copilot and adamantike July 5, 2025 23:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates Hasheous as a proxy for IGDB lookups and refactors hash-based ROM identification flows.

  • Refactored scan_handler to use single-match fetchers (fetch_playmatch_hash_match, fetch_hasheous_hash_match) and updated call sites accordingly.
  • Simplified PlaymatchHandler.lookup_rom to return a single PlaymatchRomMatch with only igdb_id.
  • Updated IGDBHandler to hardcode timeouts and use pydash.get for nested property access.
  • Enhanced HasheousHandler with proxy endpoints for IGDB and RA, a new extract_metadata_from_igdb_rom helper, and DEV_MODE switching for the base URL.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
backend/handler/scan_handler.py Renamed fetch functions, switched to single-match returns, updated asyncio.gather calls.
backend/handler/metadata/playmatch_handler.py Removed multi-match logic, updated PlaymatchRomMatch TypedDict and lookup_rom signature.
backend/handler/metadata/igdb_handler.py Dropped timeout parameter, standardized to 120s, replaced nested .get with pydash.get.
backend/handler/metadata/hasheous_handler.py Added extract_metadata_from_igdb_rom, IGDB/RA proxy methods, DEV_MODE URL toggle.
Comments suppressed due to low confidence (3)

backend/handler/scan_handler.py:484

  • New hash-based and proxy lookup flows for Hasheous are introduced here but no unit tests were added. Consider adding tests for both fetch_hasheous_hash_match and fetch_hasheous_rom to ensure correct behavior under various scan types.
    async def fetch_hasheous_rom(hasheous_rom: HasheousRom) -> HasheousRom:

backend/handler/scan_handler.py:394

  • The inner double quotes inside this f-string will cause a syntax error. Use single quotes for the dictionary key (e.g., playmatch_rom['igdb_id']) or escape the inner quotes.
                        f"{hl(str(playmatch_rom["igdb_id"]), color=BLUE)} :alien_monster:"

backend/handler/metadata/hasheous_handler.py:306

  • This f-string also contains unescaped inner double quotes. Replace with hasheous_rom['igdb_id'] to avoid a syntax error.
                f"No Hasheous game found for IGDB ID {hasheous_rom["igdb_id"]}."

@@ -610,15 +610,15 @@ async def get_matched_roms_by_name(
alternative_roms_ids = []
for rom in alternative_matched_roms:
alternative_roms_ids.append(
rom.get("game").get("id", "")
pydash.get(rom, "game.id", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid the magical pydash.get function, as we lose typing information. In this case, Mypy won't be able to alert us if we are trying to append the wrong value type to this list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I would agree, but I'd like to fix/refactor all these in 1 go in a future PR and remove all of them at once in igdb_handler

@gantoine gantoine merged commit 48ffc35 into master Jul 6, 2025
9 checks passed
@gantoine gantoine deleted the hasheous-igdb-proxy branch July 6, 2025 15:56
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.

2 participants