update frontnend to support launchbox

This commit is contained in:
Georges-Antoine Assi
2025-05-20 17:07:05 -04:00
parent 97edbbdcf9
commit 2d7c3be6ae
21 changed files with 89 additions and 20 deletions

View File

@@ -31,6 +31,8 @@ class PlatformSchema(BaseModel):
created_at: datetime
updated_at: datetime
fs_size_bytes: int
is_unidentified: bool
is_identified: bool
class Config:
from_attributes = True

View File

@@ -8,6 +8,7 @@ from endpoints.responses.assets import SaveSchema, ScreenshotSchema, StateSchema
from endpoints.responses.collection import CollectionSchema
from fastapi import Request
from handler.metadata.igdb_handler import IGDBMetadata
from handler.metadata.launchbox_handler import LaunchboxMetadata
from handler.metadata.moby_handler import MobyMetadata
from handler.metadata.ra_handler import RAMetadata
from handler.metadata.ss_handler import SSMetadata
@@ -38,6 +39,11 @@ RomRAMetadata = TypedDict( # type: ignore[misc]
dict((k, NotRequired[v]) for k, v in get_type_hints(RAMetadata).items()),
total=False,
)
RomLaunchboxMetadata = TypedDict( # type: ignore[misc]
"RomLaunchboxMetadata",
dict((k, NotRequired[v]) for k, v in get_type_hints(LaunchboxMetadata).items()),
total=False,
)
def rom_user_schema_factory() -> RomUserSchema:
@@ -173,6 +179,7 @@ class RomSchema(BaseModel):
moby_id: int | None
ss_id: int | None
ra_id: int | None
launchbox_id: int | None
platform_id: int
platform_slug: str
@@ -199,6 +206,7 @@ class RomSchema(BaseModel):
igdb_metadata: RomIGDBMetadata | None
moby_metadata: RomMobyMetadata | None
ss_metadata: RomSSMetadata | None
launchbox_metadata: RomLaunchboxMetadata | None
path_cover_small: str | None
path_cover_large: str | None
@@ -209,6 +217,7 @@ class RomSchema(BaseModel):
url_manual: str | None
is_unidentified: bool
is_identified: bool
revision: str | None
regions: list[str]

View File

@@ -178,7 +178,7 @@ def get_roms(
favourites_only (bool, optional): Filter only favourite roms. Defaults to False.
duplicates_only (bool, optional): Filter only duplicate roms. Defaults to False.
playables_only (bool, optional): Filter only playable roms by emulatorjs. Defaults to False.
group_by_meta_id (bool, optional): Group roms by igdb/moby/ssrf ID. Defaults to False.
group_by_meta_id (bool, optional): Group roms by igdb/moby/ssrf/launchbox ID. Defaults to False.
selected_genre (str, optional): Filter by genre. Defaults to None.
selected_franchise (str, optional): Filter by franchise. Defaults to None.
selected_collection (str, optional): Filter by collection. Defaults to None.
@@ -524,6 +524,7 @@ async def update_rom(
"moby_id": None,
"ss_id": None,
"ra_id": None,
"launchbox_id": None,
"name": rom.fs_name,
"summary": "",
"url_screenshots": [],
@@ -537,6 +538,7 @@ async def update_rom(
"moby_metadata": {},
"ss_metadata": {},
"ra_metadata": {},
"launchbox_metadata": {},
"revision": "",
},
)
@@ -551,6 +553,7 @@ async def update_rom(
"igdb_id": data.get("igdb_id", rom.igdb_id),
"moby_id": data.get("moby_id", rom.moby_id),
"ss_id": data.get("ss_id", rom.ss_id),
"launchbox_id": data.get("launchbox_id", rom.launchbox_id),
}
if (

View File

@@ -127,7 +127,7 @@ def _should_scan_rom(scan_type: ScanType, rom: Rom | None, roms_ids: list[str])
rom
and (
(scan_type == ScanType.UNIDENTIFIED and rom.is_unidentified)
or (scan_type == ScanType.PARTIAL and rom.is_partially_identified)
or (scan_type == ScanType.PARTIAL and rom.is_identified)
or (rom.id in roms_ids)
)
)

View File

@@ -53,6 +53,18 @@ class Platform(BaseModel):
def __repr__(self) -> str:
return self.name
@property
def is_unidentified(self) -> bool:
return not self.igdb_id and not self.moby_id and not self.ss_id
@property
def is_identified(self) -> bool:
return not self.is_unidentified
@property
def is_fully_identified(self) -> bool:
return bool(self.igdb_id) and bool(self.moby_id) and bool(self.ss_id)
@cached_property
def fs_size_bytes(self) -> int:
from handler.database import db_stats_handler

View File

@@ -311,12 +311,16 @@ class Rom(BaseModel):
@property
def is_unidentified(self) -> bool:
return (
not self.igdb_id and not self.moby_id and not self.ss_id and not self.ra_id
not self.igdb_id
and not self.moby_id
and not self.ss_id
and not self.ra_id
and not self.launchbox_id
)
@property
def is_partially_identified(self) -> bool:
return not self.is_unidentified and not self.is_fully_identified
def is_identified(self) -> bool:
return not self.is_unidentified
@property
def is_fully_identified(self) -> bool:
@@ -325,6 +329,7 @@ class Rom(BaseModel):
and bool(self.moby_id)
and bool(self.ss_id)
and bool(self.ra_id)
and bool(self.launchbox_id)
)
def has_m3u_file(self) -> bool:

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 140 KiB

View File

@@ -40,6 +40,7 @@ export type { Role } from './models/Role';
export type { RomFileCategory } from './models/RomFileCategory';
export type { RomFileSchema } from './models/RomFileSchema';
export type { RomIGDBMetadata } from './models/RomIGDBMetadata';
export type { RomLaunchboxMetadata } from './models/RomLaunchboxMetadata';
export type { RomMetadataSchema } from './models/RomMetadataSchema';
export type { RomMobyMetadata } from './models/RomMobyMetadata';
export type { RomRAMetadata } from './models/RomRAMetadata';

View File

@@ -5,6 +5,7 @@
import type { CollectionSchema } from './CollectionSchema';
import type { RomFileSchema } from './RomFileSchema';
import type { RomIGDBMetadata } from './RomIGDBMetadata';
import type { RomLaunchboxMetadata } from './RomLaunchboxMetadata';
import type { RomMetadataSchema } from './RomMetadataSchema';
import type { RomMobyMetadata } from './RomMobyMetadata';
import type { RomRAMetadata } from './RomRAMetadata';
@@ -22,6 +23,7 @@ export type DetailedRomSchema = {
moby_id: (number | null);
ss_id: (number | null);
ra_id: (number | null);
launchbox_id: (number | null);
platform_id: number;
platform_slug: string;
platform_fs_slug: string;
@@ -43,6 +45,7 @@ export type DetailedRomSchema = {
igdb_metadata: (RomIGDBMetadata | null);
moby_metadata: (RomMobyMetadata | null);
ss_metadata: (RomSSMetadata | null);
launchbox_metadata: (RomLaunchboxMetadata | null);
path_cover_small: (string | null);
path_cover_large: (string | null);
url_cover: (string | null);
@@ -50,6 +53,7 @@ export type DetailedRomSchema = {
path_manual: (string | null);
url_manual: (string | null);
is_unidentified: boolean;
is_identified: boolean;
revision: (string | null);
regions: Array<string>;
languages: Array<string>;

View File

@@ -27,6 +27,8 @@ export type PlatformSchema = {
created_at: string;
updated_at: string;
fs_size_bytes: number;
is_unidentified: boolean;
is_identified: boolean;
readonly display_name: string;
};

View File

@@ -0,0 +1,19 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type RomLaunchboxMetadata = {
release_date?: string;
max_players?: number;
release_type?: string;
cooperative?: boolean;
video_url?: string;
community_rating?: number;
community_rating_count?: number;
wikipedia_url?: string;
esrb?: string;
genres?: Array<string>;
developer?: string;
publisher?: string;
};

View File

@@ -4,6 +4,7 @@
/* eslint-disable */
import type { RomFileSchema } from './RomFileSchema';
import type { RomIGDBMetadata } from './RomIGDBMetadata';
import type { RomLaunchboxMetadata } from './RomLaunchboxMetadata';
import type { RomMetadataSchema } from './RomMetadataSchema';
import type { RomMobyMetadata } from './RomMobyMetadata';
import type { RomSSMetadata } from './RomSSMetadata';
@@ -16,6 +17,7 @@ export type SimpleRomSchema = {
moby_id: (number | null);
ss_id: (number | null);
ra_id: (number | null);
launchbox_id: (number | null);
platform_id: number;
platform_slug: string;
platform_fs_slug: string;
@@ -37,6 +39,7 @@ export type SimpleRomSchema = {
igdb_metadata: (RomIGDBMetadata | null);
moby_metadata: (RomMobyMetadata | null);
ss_metadata: (RomSSMetadata | null);
launchbox_metadata: (RomLaunchboxMetadata | null);
path_cover_small: (string | null);
path_cover_large: (string | null);
url_cover: (string | null);
@@ -44,6 +47,7 @@ export type SimpleRomSchema = {
path_manual: (string | null);
url_manual: (string | null);
is_unidentified: boolean;
is_identified: boolean;
revision: (string | null);
regions: Array<string>;
languages: Array<string>;

View File

@@ -88,7 +88,7 @@ const hasReleaseDate = Number(props.rom.metadatum.first_release_date) > 0;
</v-row>
<v-row
v-if="rom.igdb_id || rom.moby_id || rom.ss_id || rom.ra_id"
v-if="rom.is_identified"
class="text-white text-shadow mt-2"
:class="{ 'text-center': smAndDown }"
no-gutters
@@ -157,6 +157,20 @@ const hasReleaseDate = Number(props.rom.metadatum.first_release_date) > 0;
<span>{{ rom.ra_id }}</span>
</v-chip>
</a>
<div
v-if="rom.launchbox_id"
:class="{ 'ml-1': rom.igdb_id || rom.ss_id }"
>
<v-chip class="pl-0 mt-1" size="small">
<v-avatar class="mr-2" size="30" rounded="0">
<v-img src="/assets/scrappers/launchbox.png" />
</v-avatar>
<span>{{ rom.launchbox_id }}</span>
<v-divider class="mx-2 border-opacity-25" vertical />
<span>{{ rom.launchbox_metadata?.community_rating }}</span>
<v-icon class="ml-1">mdi-star</v-icon>
</v-chip>
</div>
</v-col>
</v-row>
</div>

View File

@@ -292,11 +292,7 @@ watch(
</div>
</div>
<v-row
v-if="
currentPlatform.igdb_id ||
currentPlatform.moby_id ||
currentPlatform.ss_id
"
v-if="currentPlatform.is_identified"
class="text-white text-shadow mt-2 text-center"
no-gutters
>

View File

@@ -80,10 +80,6 @@ async function removeArtwork() {
removeCover.value = true;
}
const noMetadataMatch = computed(() => {
return !rom.value?.igdb_id && !rom.value?.moby_id && !rom.value?.ss_id;
});
async function handleRomUpdate(
options: {
rom: UpdateRom;
@@ -371,8 +367,8 @@ function closeDialog() {
</v-row>
<v-row class="justify-space-between px-4 py-2 mt-1" no-gutters>
<v-btn
:disabled="noMetadataMatch"
:class="` ${noMetadataMatch ? '' : 'bg-toplayer text-romm-red'}`"
:disabled="rom.is_unidentified"
:class="` ${rom.is_unidentified ? '' : 'bg-toplayer text-romm-red'}`"
variant="flat"
@click="unmatchRom"
>

View File

@@ -8,7 +8,7 @@ const props = withDefaults(defineProps<{ rom: SimpleRom; size?: number }>(), {
});
const fallbackCoverImage = computed(() =>
props.rom.igdb_id || props.rom.moby_id
props.rom.is_identified
? getMissingCoverImage(props.rom.name || props.rom.fs_name)
: getUnmatchedCoverImage(props.rom.name || props.rom.fs_name),
);

View File

@@ -32,7 +32,7 @@ withDefaults(defineProps<{ platform: Platform; rail?: boolean }>(), {
open-delay="500"
><template #activator="{ props }">
<div
v-if="!platform.igdb_id && !platform.moby_id && !platform.ss_id"
v-if="platform.is_unidentified"
v-bind="props"
class="not-found-icon"
>

View File

@@ -206,6 +206,8 @@ async function updateRom({
if (rom.igdb_id) formData.append("igdb_id", rom.igdb_id.toString());
if (rom.moby_id) formData.append("moby_id", rom.moby_id.toString());
if (rom.ss_id) formData.append("ss_id", rom.ss_id.toString());
if (rom.launchbox_id)
formData.append("launchbox_id", rom.launchbox_id.toString());
formData.append("name", rom.name || "");
formData.append("fs_name", rom.fs_name);
formData.append("summary", rom.summary || "");

View File

@@ -357,7 +357,7 @@ async function stopScan() {
>
<template #append-body>
<v-chip
v-if="!rom.igdb_id && !rom.moby_id && !rom.ss_id"
v-if="rom.is_unidentified"
color="red"
size="x-small"
label