[ROMM-2547] Flashpoint scrape by ID

This commit is contained in:
Georges-Antoine Assi
2025-10-18 22:18:42 -04:00
parent 4b42249cef
commit ad5525c484
2 changed files with 17 additions and 1 deletions

View File

@@ -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)

View File

@@ -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