Skip to content

Commit

Permalink
Merge branch 'master' into rom-fetch-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed May 26, 2024
2 parents 1677b58 + c6ae4e3 commit 7e34b6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion backend/endpoints/sockets/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ async def scan_platforms(
if platform and scan_type == ScanType.NEW_PLATFORMS:
continue

scanned_platform = scan_platform(platform_slug, fs_platforms)
scanned_platform = scan_platform(
platform_slug, fs_platforms, metadata_sources=metadata_sources
)
if platform:
scanned_platform.id = platform.id
# Keep the existing ids if they exist on the platform
Expand Down
15 changes: 13 additions & 2 deletions backend/handler/scan_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
fs_rom_handler,
)
from handler.metadata import meta_igdb_handler, meta_moby_handler
from handler.metadata.igdb_handler import IGDBPlatform
from handler.metadata.moby_handler import MobyGamesPlatform
from logger.logger import log
from models.assets import Save, Screenshot, State
from models.platform import Platform
Expand Down Expand Up @@ -48,6 +50,7 @@ def _get_main_platform_igdb_id(platform: Platform):
def scan_platform(
fs_slug: str,
fs_platforms: list[str],
metadata_sources: list[str] = ["igdb", "moby"],
) -> Platform:
"""Get platform details
Expand Down Expand Up @@ -83,8 +86,16 @@ def scan_platform(
except (KeyError, TypeError, AttributeError):
platform_attrs["slug"] = fs_slug

igdb_platform = meta_igdb_handler.get_platform(platform_attrs["slug"])
moby_platform = meta_moby_handler.get_platform(platform_attrs["slug"])
igdb_platform = (
meta_igdb_handler.get_platform(platform_attrs["slug"])
if "igdb" in metadata_sources
else IGDBPlatform(igdb_id=None, slug=platform_attrs["slug"])
)
moby_platform = (
meta_moby_handler.get_platform(platform_attrs["slug"])
if "moby" in metadata_sources
else MobyGamesPlatform(moby_id=None, slug=platform_attrs["slug"])
)

platform_attrs["name"] = platform_attrs["slug"].replace("-", " ").title()
platform_attrs.update({**moby_platform, **igdb_platform}) # Reverse order
Expand Down

0 comments on commit 7e34b6b

Please sign in to comment.