From ad5525c484b9c2e1da88edebbdf69284e552e0e5 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sat, 18 Oct 2025 22:18:42 -0400 Subject: [PATCH] [ROMM-2547] Flashpoint scrape by ID --- backend/handler/metadata/flashpoint_handler.py | 7 ++++++- backend/utils/__init__.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/handler/metadata/flashpoint_handler.py b/backend/handler/metadata/flashpoint_handler.py index 8f812a95c..ea0371645 100644 --- a/backend/handler/metadata/flashpoint_handler.py +++ b/backend/handler/metadata/flashpoint_handler.py @@ -9,7 +9,7 @@ from fastapi import HTTPException, status from config import FLASHPOINT_API_ENABLED from logger.logger import log -from utils import get_version +from utils import get_version, is_valid_uuid from utils.context import ctx_httpx_client from .base_handler import MetadataHandler @@ -243,6 +243,11 @@ class FlashpointHandler(MetadataHandler): if platform_slug not in FLASHPOINT_PLATFORM_LIST: return FlashpointRom(flashpoint_id=None) + # Check if the filename is a UUID + fs_name_no_tags = fs_rom_handler.get_file_name_with_no_tags(fs_name) + if is_valid_uuid(fs_name_no_tags): + return await self.get_rom_by_id(flashpoint_id=fs_name_no_tags) + # Normalize the search term search_term = fs_rom_handler.get_file_name_with_no_tags(fs_name) search_term = self.normalize_search_term(search_term, remove_punctuation=False) diff --git a/backend/utils/__init__.py b/backend/utils/__init__.py index a0861fc26..bc1fdd441 100644 --- a/backend/utils/__init__.py +++ b/backend/utils/__init__.py @@ -1,3 +1,5 @@ +import uuid + from __version__ import __version__ @@ -7,3 +9,12 @@ def get_version() -> str: return __version__ return "development" + + +def is_valid_uuid(uuid_str: str) -> bool: + """Check if a string is a valid UUID.""" + try: + uuid.UUID(uuid_str, version=4) + return True + except ValueError: + return False