mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
[ROMM-2547] Flashpoint scrape by ID
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user