Skip to content

Commit

Permalink
Merge pull request #863 from rommapp/romm-834
Browse files Browse the repository at this point in the history
[ROMMM-834] Fix search by ID for mobygames
  • Loading branch information
zurdi15 committed May 23, 2024
2 parents c6d9d1f + 7b61972 commit 00f1c1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion backend/handler/metadata/igdb_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ def get_matched_roms_by_id(self, igdb_id: int) -> list[IGDBRom]:
if not IGDB_API_ENABLED:
return []

return [self.get_rom_by_id(igdb_id)]
rom = self.get_rom_by_id(igdb_id)
return [rom] if rom["igdb_id"] else []

@check_twitch_token
def get_matched_roms_by_name(
Expand Down
7 changes: 4 additions & 3 deletions backend/handler/metadata/moby_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ async def get_rom(self, file_name: str, platform_moby_id: int) -> MobyGamesRom:

def get_rom_by_id(self, moby_id: int) -> MobyGamesRom:
if not MOBY_API_ENABLED:
return MobyGamesRom(moby_id=moby_id)
return MobyGamesRom(moby_id=None)

url = yarl.URL(self.games_url).with_query(id=moby_id)
roms = self._request(str(url)).get("games", [])
res = pydash.get(roms, "[0]", None)

if not res:
return MobyGamesRom(moby_id=moby_id)
return MobyGamesRom(moby_id=None)

rom = {
"moby_id": res["game_id"],
Expand All @@ -278,7 +278,8 @@ def get_matched_roms_by_id(self, moby_id: int) -> list[MobyGamesRom]:
if not MOBY_API_ENABLED:
return []

return [self.get_rom_by_id(moby_id)]
rom = self.get_rom_by_id(moby_id)
return [rom] if rom["moby_id"] else []

def get_matched_roms_by_name(
self, search_term: str, platform_moby_id: int
Expand Down

0 comments on commit 00f1c1b

Please sign in to comment.