mirror of
https://github.com/rommapp/romm.git
synced 2026-12-06 07:54:18 +01:00
fix flashpoint search
This commit is contained in:
8 files changed
+99
-11
No files matched your search
@@ -7,6 +7,7 @@ class SearchRomSchema(BaseModel):
|
||||
moby_id: int | None = None
|
||||
ss_id: int | None = None
|
||||
sgdb_id: int | None = None
|
||||
flashpoint_id: str | None = None
|
||||
platform_id: int
|
||||
name: str
|
||||
slug: str = ""
|
||||
@@ -15,6 +16,9 @@ class SearchRomSchema(BaseModel):
|
||||
moby_url_cover: str = ""
|
||||
ss_url_cover: str = ""
|
||||
sgdb_url_cover: str = ""
|
||||
flashpoint_url_cover: str = ""
|
||||
is_unidentified: bool
|
||||
is_identified: bool
|
||||
|
||||
|
||||
class SearchCoverSchema(BaseModel):
|
||||
|
||||
@@ -13,7 +13,10 @@ from handler.metadata import (
|
||||
meta_sgdb_handler,
|
||||
meta_ss_handler,
|
||||
)
|
||||
from handler.metadata.flashpoint_handler import FlashpointRom
|
||||
from handler.metadata.flashpoint_handler import (
|
||||
FLASHPOINT_API_ENABLED,
|
||||
FlashpointRom,
|
||||
)
|
||||
from handler.metadata.igdb_handler import IGDB_API_ENABLED, IGDBRom
|
||||
from handler.metadata.moby_handler import MOBY_API_ENABLED, MobyGamesRom
|
||||
from handler.metadata.sgdb_handler import STEAMGRIDDB_API_ENABLED, SGDBRom
|
||||
@@ -52,7 +55,12 @@ async def search_rom(
|
||||
list[SearchRomSchema]: List of matched roms
|
||||
"""
|
||||
|
||||
if not IGDB_API_ENABLED and not SS_API_ENABLED and not MOBY_API_ENABLED:
|
||||
if (
|
||||
not IGDB_API_ENABLED
|
||||
and not SS_API_ENABLED
|
||||
and not MOBY_API_ENABLED
|
||||
and not FLASHPOINT_API_ENABLED
|
||||
):
|
||||
log.error("Search error: No metadata providers enabled")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -126,6 +134,8 @@ async def search_rom(
|
||||
)
|
||||
merged_dict[igdb_name] = {
|
||||
**igdb_rom,
|
||||
"is_identified": True,
|
||||
"is_unidentified": False,
|
||||
"platform_id": rom.platform_id,
|
||||
"igdb_url_cover": igdb_rom.pop("url_cover", ""),
|
||||
**merged_dict.get(igdb_name, {}),
|
||||
@@ -139,6 +149,8 @@ async def search_rom(
|
||||
)
|
||||
merged_dict[moby_name] = {
|
||||
**moby_rom,
|
||||
"is_identified": True,
|
||||
"is_unidentified": False,
|
||||
"platform_id": rom.platform_id,
|
||||
"moby_url_cover": moby_rom.pop("url_cover", ""),
|
||||
**merged_dict.get(moby_name, {}),
|
||||
@@ -152,6 +164,8 @@ async def search_rom(
|
||||
)
|
||||
merged_dict[ss_name] = {
|
||||
**ss_rom,
|
||||
"is_identified": True,
|
||||
"is_unidentified": False,
|
||||
"platform_id": rom.platform_id,
|
||||
"ss_url_cover": ss_rom.pop("url_cover", ""),
|
||||
**merged_dict.get(ss_name, {}),
|
||||
@@ -165,6 +179,8 @@ async def search_rom(
|
||||
)
|
||||
merged_dict[flashpoint_name] = {
|
||||
**flashpoint_rom,
|
||||
"is_identified": True,
|
||||
"is_unidentified": False,
|
||||
"platform_id": rom.platform_id,
|
||||
"flashpoint_url_cover": flashpoint_rom.pop("url_cover", ""),
|
||||
**merged_dict.get(flashpoint_name, {}),
|
||||
|
||||
@@ -240,13 +240,18 @@ class FlashpointHandler(MetadataHandler):
|
||||
log.debug(f"No good match found for '{search_term}' on Flashpoint")
|
||||
return FlashpointRom(flashpoint_id=None)
|
||||
|
||||
async def get_matched_roms_by_name(self, search_term: str) -> list[FlashpointRom]:
|
||||
async def get_matched_roms_by_name(self, fs_name: str) -> list[FlashpointRom]:
|
||||
"""
|
||||
Get ROM information by name from Flashpoint.
|
||||
"""
|
||||
from handler.filesystem import fs_rom_handler
|
||||
|
||||
if not FLASHPOINT_API_ENABLED:
|
||||
return []
|
||||
|
||||
search_term = fs_rom_handler.get_file_name_with_no_tags(fs_name)
|
||||
search_term = self.normalize_search_term(search_term, remove_punctuation=False)
|
||||
|
||||
games = await self.search_games(search_term)
|
||||
return [
|
||||
FlashpointRom(
|
||||
|
||||
@@ -8,6 +8,7 @@ export type SearchRomSchema = {
|
||||
moby_id?: (number | null);
|
||||
ss_id?: (number | null);
|
||||
sgdb_id?: (number | null);
|
||||
flashpoint_id?: (string | null);
|
||||
platform_id: number;
|
||||
name: string;
|
||||
slug?: string;
|
||||
@@ -16,5 +17,8 @@ export type SearchRomSchema = {
|
||||
moby_url_cover?: string;
|
||||
ss_url_cover?: string;
|
||||
sgdb_url_cover?: string;
|
||||
flashpoint_url_cover?: string;
|
||||
is_unidentified: boolean;
|
||||
is_identified: boolean;
|
||||
};
|
||||
|
||||
@@ -99,7 +99,7 @@ const computedAspectRatio = computed(() => {
|
||||
return parseFloat(ratio.toString());
|
||||
});
|
||||
const fallbackCoverImage = computed(() =>
|
||||
props.rom.igdb_id || props.rom.moby_id || props.rom.ss_id
|
||||
props.rom.is_identified
|
||||
? getMissingCoverImage(props.rom.name || props.rom.slug || "")
|
||||
: getUnmatchedCoverImage(props.rom.name || props.rom.slug || ""),
|
||||
);
|
||||
|
||||
@@ -48,5 +48,18 @@ defineProps<{ rom: SearchRomSchema }>();
|
||||
>
|
||||
<v-img src="/assets/scrappers/ss.png" /></v-avatar></template
|
||||
></v-tooltip>
|
||||
<v-tooltip
|
||||
location="top"
|
||||
class="tooltip"
|
||||
transition="fade-transition"
|
||||
text="Flashpoint matched"
|
||||
open-delay="500"
|
||||
>
|
||||
<template #activator="{ props }">
|
||||
<v-avatar v-bind="props" v-if="rom.flashpoint_id" size="30" rounded="1">
|
||||
<v-img src="/assets/scrappers/flashpoint.png" />
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</v-row>
|
||||
</template>
|
||||
@@ -19,7 +19,7 @@ import { getMissingCoverImage } from "@/utils/covers";
|
||||
|
||||
type MatchedSource = {
|
||||
url_cover: string | undefined;
|
||||
name: "IGDB" | "Mobygames" | "Screenscraper" | "SteamGridDB";
|
||||
name: "IGDB" | "Mobygames" | "Screenscraper" | "Flashpoint" | "SteamGridDB";
|
||||
logo_path: string;
|
||||
};
|
||||
|
||||
@@ -47,6 +47,7 @@ const heartbeat = storeHeartbeat();
|
||||
const isIGDBFiltered = ref(true);
|
||||
const isMobyFiltered = ref(true);
|
||||
const isSSFiltered = ref(true);
|
||||
const isFlashpointFiltered = ref(true);
|
||||
const computedAspectRatio = computed(() => {
|
||||
const ratio =
|
||||
platfotmsStore.getAspectRatio(rom.value?.platform_id ?? -1) ||
|
||||
@@ -60,10 +61,9 @@ emitter?.on("showMatchRomDialog", (romToSearch) => {
|
||||
|
||||
// Use name as search term, only when it's matched
|
||||
// Otherwise use the filename without tags and extensions
|
||||
searchText.value =
|
||||
romToSearch.igdb_id || romToSearch.moby_id || romToSearch.ss_id
|
||||
? (romToSearch.name ?? "")
|
||||
: romToSearch.fs_name_no_tags;
|
||||
searchText.value = romToSearch.is_identified
|
||||
? (romToSearch.name ?? "")
|
||||
: romToSearch.fs_name_no_tags;
|
||||
});
|
||||
const missingCoverImage = computed(() =>
|
||||
getMissingCoverImage(rom.value?.name || rom.value?.fs_name || ""),
|
||||
@@ -82,12 +82,18 @@ function toggleSourceFilter(source: MatchedSource["name"]) {
|
||||
heartbeat.value.METADATA_SOURCES.SS_API_ENABLED
|
||||
) {
|
||||
isSSFiltered.value = !isSSFiltered.value;
|
||||
} else if (
|
||||
source == "Flashpoint" &&
|
||||
heartbeat.value.METADATA_SOURCES.FLASHPOINT_API_ENABLED
|
||||
) {
|
||||
isFlashpointFiltered.value = !isFlashpointFiltered.value;
|
||||
}
|
||||
filteredMatchedRoms.value = matchedRoms.value.filter((rom) => {
|
||||
if (
|
||||
(rom.igdb_id && isIGDBFiltered.value) ||
|
||||
(rom.moby_id && isMobyFiltered.value) ||
|
||||
(rom.ss_id && isSSFiltered.value)
|
||||
(rom.ss_id && isSSFiltered.value) ||
|
||||
(rom.flashpoint_id && isFlashpointFiltered.value)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -117,7 +123,8 @@ async function searchRom() {
|
||||
if (
|
||||
(rom.igdb_id && isIGDBFiltered.value) ||
|
||||
(rom.moby_id && isMobyFiltered.value) ||
|
||||
(rom.ss_id && isSSFiltered.value)
|
||||
(rom.ss_id && isSSFiltered.value) ||
|
||||
(rom.flashpoint_id && isFlashpointFiltered.value)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -175,6 +182,13 @@ function showSources(matchedRom: SearchRomSchema) {
|
||||
logo_path: "/assets/scrappers/sgdb.png",
|
||||
});
|
||||
}
|
||||
if (matchedRom.flashpoint_url_cover) {
|
||||
sources.value.push({
|
||||
url_cover: matchedRom.flashpoint_url_cover,
|
||||
name: "Flashpoint",
|
||||
logo_path: "/assets/scrappers/flashpoint.png",
|
||||
});
|
||||
}
|
||||
if (sources.value.length == 1) {
|
||||
selectedCover.value = sources.value[0];
|
||||
}
|
||||
@@ -232,6 +246,7 @@ async function updateRom(
|
||||
selectedRom.igdb_url_cover ||
|
||||
selectedRom.ss_url_cover ||
|
||||
selectedRom.moby_url_cover ||
|
||||
selectedRom.flashpoint_url_cover ||
|
||||
null,
|
||||
};
|
||||
|
||||
@@ -379,6 +394,35 @@ onBeforeUnmount(() => {
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
<v-tooltip
|
||||
location="top"
|
||||
class="tooltip"
|
||||
transition="fade-transition"
|
||||
:text="
|
||||
heartbeat.value.METADATA_SOURCES.FLASHPOINT_API_ENABLED
|
||||
? 'Filter Flashpoint matches'
|
||||
: 'Flashpoint source is not enabled'
|
||||
"
|
||||
open-delay="500"
|
||||
><template #activator="{ props }">
|
||||
<v-avatar
|
||||
@click="toggleSourceFilter('Flashpoint')"
|
||||
v-bind="props"
|
||||
class="ml-3 cursor-pointer opacity-40"
|
||||
:class="{
|
||||
'opacity-100':
|
||||
isFlashpointFiltered &&
|
||||
heartbeat.value.METADATA_SOURCES.FLASHPOINT_API_ENABLED,
|
||||
'cursor-not-allowed':
|
||||
!heartbeat.value.METADATA_SOURCES.FLASHPOINT_API_ENABLED,
|
||||
}"
|
||||
size="30"
|
||||
rounded="1"
|
||||
>
|
||||
<v-img src="/assets/scrappers/flashpoint.png" />
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<v-row class="align-center" no-gutters>
|
||||
|
||||
@@ -253,6 +253,8 @@ async function updateRom({
|
||||
if (rom.ss_id) formData.append("ss_id", rom.ss_id.toString());
|
||||
if (rom.launchbox_id)
|
||||
formData.append("launchbox_id", rom.launchbox_id.toString());
|
||||
if (rom.flashpoint_id)
|
||||
formData.append("flashpoint_id", rom.flashpoint_id.toString());
|
||||
formData.append("name", rom.name || "");
|
||||
formData.append("fs_name", rom.fs_name);
|
||||
formData.append("summary", rom.summary || "");
|
||||
|
||||
Reference in new issue
Block a user