Merge pull request #2071 from rommapp/4-metadata-fixes-4

I lied, more fixes
This commit is contained in:
Georges-Antoine Assi
2025-07-12 20:59:47 -04:00
committed by GitHub
7 changed files with 149 additions and 50 deletions

View File

@@ -1,5 +1,6 @@
from datetime import datetime
from handler.metadata.moby_handler import MOBYGAMES_PLATFORM_LIST
from models.platform import DEFAULT_COVER_ASPECT_RATIO
from pydantic import Field, computed_field, field_validator
@@ -36,7 +37,6 @@ class PlatformSchema(BaseModel):
fs_size_bytes: int
is_unidentified: bool
is_identified: bool
missing_from_fs: bool
class Config:
@@ -50,3 +50,14 @@ class PlatformSchema(BaseModel):
@field_validator("firmware")
def sort_files(cls, v: list[FirmwareSchema]) -> list[FirmwareSchema]:
return sorted(v, key=lambda x: x.file_name)
@computed_field # type: ignore
@property
def moby_slug(self) -> str | None:
if not self.moby_id:
return None
if self.slug not in MOBYGAMES_PLATFORM_LIST:
return None
return MOBYGAMES_PLATFORM_LIST[self.slug].get("slug", None)

View File

@@ -62,21 +62,14 @@ class Platform(BaseModel):
and not self.moby_id
and not self.ss_id
and not self.launchbox_id
and not self.ra_id
and not self.hasheous_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)
and bool(self.launchbox_id)
)
@cached_property
def fs_size_bytes(self) -> int:
from handler.database import db_stats_handler

View File

@@ -327,22 +327,13 @@ class Rom(BaseModel):
and not self.ss_id
and not self.ra_id
and not self.launchbox_id
and not self.hasheous_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)
and bool(self.ra_id)
and bool(self.launchbox_id)
)
def has_m3u_file(self) -> bool:
"""
Check if the ROM has an M3U file associated with it.

View File

@@ -13,6 +13,7 @@ export type PlatformSchema = {
igdb_id?: (number | null);
sgdb_id?: (number | null);
moby_id?: (number | null);
moby_slug?: (string | null);
launchbox_id?: (number | null);
ss_id?: (number | null);
ra_id?: (number | null);

View File

@@ -4,7 +4,7 @@ import RDialog from "@/components/common/RDialog.vue";
import RAvatar from "@/components/common/Collection/RAvatar.vue";
import type { DetailedRom } from "@/stores/roms";
import { ROUTES } from "@/plugins/router";
import { ref } from "vue";
import { computed, ref } from "vue";
import { useRouter } from "vue-router";
import { useDisplay, useTheme } from "vuetify";
import { useI18n } from "vue-i18n";
@@ -12,8 +12,8 @@ import { MdPreview } from "md-editor-v3";
import { get } from "lodash";
// Props
const props = defineProps<{ rom: DetailedRom }>();
const { t } = useI18n();
defineProps<{ rom: DetailedRom }>();
const { xs } = useDisplay();
const theme = useTheme();
const show = ref(false);
@@ -36,6 +36,60 @@ const filters = [
{ key: "companies", path: "metadatum.companies", name: t("rom.companies") },
] as const;
const dataSources = computed(() => {
return [
{
name: "IGDB",
condition: props.rom.igdb_id,
url: `https://www.igdb.com/games/${props.rom.slug}`,
},
{
name: "ScreenScraper",
condition: props.rom.ss_id,
url: `https://www.screenscraper.fr/gameinfos.php?gameid=${props.rom.ss_id}`,
},
{
name: "MobyGames",
condition: props.rom.moby_id,
url: `https://www.mobygames.com/game/${props.rom.moby_id}`,
},
{
name: "LaunchBox",
condition: props.rom.launchbox_id,
url: `https://gamesdb.launchbox-app.com/games/details/${props.rom.launchbox_id}`,
},
{
name: "RetroAchievements",
condition: props.rom.ra_id,
url: `https://retroachievements.org/game/${props.rom.ra_id}`,
},
{
name: "Hasheous",
condition: props.rom.hasheous_id,
url: `https://hasheous.org/index.html?page=dataobjectdetail&type=game&id=${props.rom.hasheous_id}`,
},
].filter((source) => source.condition);
});
const coverImageSource = computed(() => {
if (!props.rom.url_cover) return null;
try {
const hostname = new URL(props.rom.url_cover).hostname;
if (hostname == "images.igdb.com") return "IGDB";
if (hostname == "screenscraper.fr") return "ScreenScraper";
if (hostname == "cdn.mobygames.com") return "MobyGames";
if (hostname == "images.launchbox-app.com") return "LaunchBox";
if (hostname == "media.retroachievements.org") return "RetroAchievements";
if (hostname == "cdn2.steamgriddb.com") return "SteamGridDB";
return null;
} catch (error) {
return null;
}
});
// Functions
function onFilterClick(filter: FilterType, value: string) {
router.push({
@@ -245,6 +299,32 @@ function onFilterClick(filter: FilterType, value: string) {
</v-col>
</v-row>
</template>
<v-row v-if="rom.is_identified">
<v-col class="mt-4 text-right">
<div class="text-grey">
Data provided by
<template v-for="(source, index) in dataSources" :key="source.name">
<a
v-if="source.condition"
style="color: inherit"
:href="source.url"
target="_blank"
>
{{ source.name }}
</a>
<span v-if="source.condition && index < dataSources.length - 1">
{{ index === dataSources.length - 2 ? " and " : ", " }}
</span> </template
>.
</div>
<div v-if="rom.url_cover && coverImageSource" class="text-grey mt-1">
Cover image provided by
<a :href="rom.url_cover" target="_blank" style="color: inherit">
{{ coverImageSource }}</a
>.
</div>
</v-col>
</v-row>
</v-col>
</v-row>
</template>

View File

@@ -188,22 +188,30 @@ const hashMatches = computed(() => {
<v-icon class="ml-1">mdi-star</v-icon>
</v-chip>
</a>
<v-chip
<a
v-if="rom.launchbox_id"
class="pl-0 mt-1 mr-1"
size="small"
title="LaunchBox ID"
style="text-decoration: none; color: inherit"
:href="`https://gamesdb.launchbox-app.com/games/details/${rom.launchbox_id}`"
target="_blank"
class="mr-1"
>
<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?.toFixed(2)
}}</span>
<v-icon class="ml-1">mdi-star</v-icon>
</v-chip>
<v-chip
class="pl-0 mt-1"
size="small"
@click.stop
title="LaunchBox ID"
>
<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?.toFixed(2)
}}</span>
<v-icon class="ml-1">mdi-star</v-icon>
</v-chip>
</a>
<a
v-if="rom.ra_id"
style="text-decoration: none; color: inherit"
@@ -219,14 +227,21 @@ const hashMatches = computed(() => {
<span>{{ rom.ra_id }}</span>
</v-chip>
</a>
<span v-if="rom.hasheous_id" class="mr-1">
<v-chip class="pl-0 mt-1" size="small">
<a
v-if="rom.hasheous_id"
style="text-decoration: none; color: inherit"
:href="`https://hasheous.org/index.html?page=dataobjectdetail&type=game&id=${rom.hasheous_id}`"
target="_blank"
class="mr-1"
title="Hasheous ID"
>
<v-chip tabindex="-1" class="px-2 mt-1" size="small" @click.stop>
<v-avatar class="mr-2 pa-1" size="30" rounded="0">
<v-img src="/assets/scrappers/hasheous.png" />
</v-avatar>
<span>{{ rom.hasheous_id }}</span>
</v-chip>
</span>
</a>
<a
v-if="rom.sgdb_id"
style="text-decoration: none; color: inherit"

View File

@@ -326,7 +326,7 @@ watch(
<a
v-if="currentPlatform.ss_id"
style="text-decoration: none; color: inherit"
:href="`https://www.screenscraper.fr/systemeinfos.php?plateforme=${currentPlatform.ss_id}`"
:href="`https://www.screenscraper.fr/gamesinfos.php?plateforme=${currentPlatform.ss_id}`"
target="_blank"
class="ml-1"
:tabindex="tabIndex"
@@ -339,8 +339,9 @@ watch(
</v-chip>
</a>
<a
v-if="currentPlatform.moby_id"
v-if="currentPlatform.moby_slug"
style="text-decoration: none; color: inherit"
:href="`https://www.mobygames.com/platform/${currentPlatform.moby_slug}`"
target="_blank"
class="ml-1"
:tabindex="tabIndex"
@@ -355,6 +356,7 @@ watch(
<a
v-if="currentPlatform.ra_id"
style="text-decoration: none; color: inherit"
:href="`https://retroachievements.org/system/${currentPlatform.ra_id}/games`"
target="_blank"
class="ml-1"
:tabindex="tabIndex"
@@ -369,8 +371,10 @@ watch(
<a
v-if="currentPlatform.launchbox_id"
style="text-decoration: none; color: inherit"
:href="`https://gamesdb.launchbox-app.com/platforms/games/${currentPlatform.launchbox_id}`"
target="_blank"
class="ml-1"
:tabindex="tabIndex"
>
<v-chip class="pl-0 mt-1" size="small" @click.stop>
<v-avatar class="mr-2" size="25" rounded="1">
@@ -379,17 +383,21 @@ watch(
<span>{{ currentPlatform.launchbox_id }}</span>
</v-chip>
</a>
<v-chip
<a
v-if="currentPlatform.hasheous_id"
class="pl-0 mt-1 ml-1"
size="small"
@click.stop
style="text-decoration: none; color: inherit"
:href="`https://hasheous.org/index.html?page=dataobjectdetail&type=platform&id=${currentPlatform.hasheous_id}`"
target="_blank"
class="ml-1"
:tabindex="tabIndex"
>
<v-avatar class="mr-2 pa-1" size="30" rounded="0">
<v-img src="/assets/scrappers/hasheous.png" />
</v-avatar>
<span>{{ currentPlatform.hasheous_id }}</span>
</v-chip>
<v-chip class="pl-0 mt-1" size="small" @click.stop>
<v-avatar class="mr-2" size="25" rounded="1">
<v-img src="/assets/scrappers/hasheous.png" />
</v-avatar>
<span>{{ currentPlatform.hasheous_id }}</span>
</v-chip>
</a>
</v-col>
</v-row>
<v-card class="mt-4 bg-toplayer fill-width" elevation="0">