From 63e58d3e15218be9ab72138bd6a5839e0dec8718 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 25 May 2024 18:07:05 -0400 Subject: [PATCH] [ROMM-867] Only scan platform when selected --- backend/endpoints/sockets/scan.py | 4 +++- backend/handler/scan_handler.py | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backend/endpoints/sockets/scan.py b/backend/endpoints/sockets/scan.py index 6da90d363..473dd1b4a 100644 --- a/backend/endpoints/sockets/scan.py +++ b/backend/endpoints/sockets/scan.py @@ -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 diff --git a/backend/handler/scan_handler.py b/backend/handler/scan_handler.py index a1d058400..0a6eceb40 100644 --- a/backend/handler/scan_handler.py +++ b/backend/handler/scan_handler.py @@ -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 @@ -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 @@ -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